Rumus Button Pada Android

code button di android nu bener

Main.java

package com.al_quran;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

public class MainActivity extends Activity implements OnClickListener {
ImageButton imageButton;


@Override
public void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ImageButton imageButton=(ImageButton) findViewById(R.id.imageButton);
imageButton.setOnClickListener(this);

ImageButton imageButton1=(ImageButton) findViewById(R.id.imageButton1);
imageButton1.setOnClickListener(this);

ImageButton imageButton2=(ImageButton) findViewById(R.id.imageButton2);
imageButton2.setOnClickListener(this);
}
public void onClick(View arg0) {
if(arg0.getId() == R.id.imageButton){
Intent i = new Intent(this, Jpage2.class);
startActivity(i);}

if(arg0.getId() == R.id.imageButton1){
Intent i = new Intent(this, Jpage3.class);
startActivity(i);}

if(arg0.getId() == R.id.imageButton2){
Intent i = new Intent(this, Jpage4.class);
startActivity(i);}
}

}



Main.java 2
package com.al_quran;
  import android.app.ListActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.TextView;

public class Jpage2 extends ListActivity {
TextView Jpage2;
String [] pilihan2 = {
"Al-Fatihah (7)", " Al-Baqarah (286)", "Ali 'Imran", " An-Nisa'", "Al-Ma'idah", "Al-An'am ", "Al-A’raf", "Al-Anfal", " At-Taubah", "Yunus", "Hud", "Yusuf", "Ar-Ra’d", " Ibrahim", "Al-Hijr", " An-Nahl ", "Al-Isra'",   " Al-Kahf",   "Maryam",   "Ta Ha", " Al-Anbiya",   "Al-Hajj", "Al-Mu’minun",   "An-Nur", "Al-Furqan",   "Asy-Syu'ara'",   "An-Naml", " Al-Qasas ", " Al-'Ankabut", "Ar-Rum", "Luqman", "As-Sajdah", "Al-Ahzab", "Saba’", "Fatir ",
"Ya Sin", "As-Saffat", "Sad", "Az-Zumar", "Al-Mu’min", "Fussilat", "Asy-Syura", " Az-Zukhruf",   "Ad-Dukhan",   "Al-Jasiyah", "Al-Ahqaf",   "Muhammad",   "Al-Fath",
" Al-Hujurat",   "Qaf", "Az-Zariyat",   "At-Tur", "An-Najm",   "Al-Qamar", "Ar-Rahman",  "Al-Waqi’ah", "Al-Hadid",   "Al-Mujadilah",    "Al-Hasyr", "Al-Mumtahanah", "As-Saff",
"Al-Jumu’ah",   " Al-Munafiqun",   " At-Tagabun", "At-Talaq",   " At-Tahrim",   "Al-Mulk", "Al-Qalam",   " Al-Haqqah", "Al-Ma’arij", "Nuh", "Al-Jinn", "Al-Muzzammil"};
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.page2);
setListAdapter(new ArrayAdapter <String>
(this,android.R.layout.simple_list_item_1,pilihan2));
Jpage2 = (TextView) findViewById(R.id.yangDipilih2);
}
public void onListItemClick(ListView parent, View v,
  int position, long id) {
  Jpage2.setText(pilihan2[position]);
}
}


activiti.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#034a01"
    android:paddingTop="4dp"
    android:paddingRight="4dp"
    android:paddingLeft="4dp"
    android:paddingBottom="4dp"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:src="@drawable/santri"
        tools:ignore="ContentDescription" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:src="@drawable/alquranciamis"
        tools:ignore="ContentDescription" />

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="14dp"
        android:src="@drawable/arab"
        tools:ignore="ContentDescription" />

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/imageButton"
        android:layout_below="@+id/imageButton"
        android:src="@drawable/terjemah"
        tools:ignore="ContentDescription" />

    <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/imageButton1"
        android:layout_below="@+id/imageButton1"
        android:src="@drawable/alqurandanterjemah"
        tools:ignore="ContentDescription" />

</RelativeLayout>




activity xml 2

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#034a01"
    android:orientation="vertical"
    android:gravity="center_horizontal"
    android:paddingTop="4dp"
    android:paddingRight="4dp"
    android:paddingLeft="4dp"
    android:paddingBottom="4dp"
    tools:ignore="SelectableText" >

    <TextView
        android:id="@+id/yangDipilih2"
        android:layout_width="fill_parent"
        android:layout_height="35dp"
        android:textColor="#ffffff"
        android:textSize="10pt"/>

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#937603"
        android:fitsSystemWindows="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:scrollbarAlwaysDrawVerticalTrack="false" />

</LinearLayout>

Posting Komentar untuk "Rumus Button Pada Android"