xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cccccc"
android:gravity="right"
tools:context=".MainActivity" >
<ScrollView
android:layout_marginBottom="50dip"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#cccccc"
>
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#fff">
<ImageView
android:id="@+id/myGambar"
android:layout_centerHorizontal="true"
android:src="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TableRow android:id="@+id/TableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Nama Tanaman" />
<TextView android:id="@+id/detailNamaTanaman" />
</TableRow>
<TableRow android:id="@+id/TableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Kegunaan" />
<TextView android:id="@+id/detailKegunaan" />
</TableRow>
<TableRow android:id="@+id/TableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="Deskripsi" />
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="164dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/isi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="isi" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
</TableRow>
<Button
android:id="@+id/btnWiki"
android:text="Wikipedia"
/>
<Button
android:id="@+id/btnKembali"
android:text="Kembali"
/>
</TableLayout>
</ScrollView>
</RelativeLayout>
package lp2maray.com;
import java.util.Calendar;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
public class Detail extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail);
Intent io = this.getIntent();
String nama=io.getStringExtra("nama");
String kegunaan=io.getStringExtra("kegunaan");
String deskripsi=io.getStringExtra("deskripsi");
int gambar=io.getIntExtra("gambar", R.drawable.logo);
TextView txtNama=(TextView)findViewById(R.id.detailNamaTanaman);
TextView txtKegunaan=(TextView)findViewById(R.id.detailKegunaan);
TextView txtDeskripsi=(TextView)findViewById(R.id.isi);
ImageView myGambar=(ImageView)findViewById(R.id.myGambar);
txtNama.setText(nama);
txtKegunaan.setText(kegunaan);
txtDeskripsi.setText(deskripsi);
myGambar.setImageResource(gambar);
Button btnKembali=(Button)findViewById(R.id.btnKembali);
btnKembali.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
finish();
}});
Button btnWikipedia=(Button)findViewById(R.id.btnWiki);
btnWikipedia.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://id.wikipedia.org/wiki/Tanaman_obat_keluarga"));
startActivity(browserIntent);
}});
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
Tidak ada komentar:
Posting Komentar