Berikut kami tampilkan Source Code nya :
Main.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="20sp" >
</TextView>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="20sp" >
</TextView>
ListViewActivity.java
package com.jajal.listview;
import android.app.Activity;
import android.os.Bundle;
import android.app.ListActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class ListviewActivity extends ListActivity {
static final String[] TEAMWORK = new String[] { "Akbar Seto Ramadhan (A11.2011.05937)", "Galuh Adjeng Sekarsari (A11.2011.05996)", "Izzi Abdul Salam S (A11.2011.05832)",
"M. Chair Ziaulahq (A11.2011.06280)", "Muhammad Risman N (A11.2011.06152)"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.main,TEAMWORK));
ListView listView = getListView();
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(),
((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
import android.app.Activity;
import android.os.Bundle;
import android.app.ListActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class ListviewActivity extends ListActivity {
static final String[] TEAMWORK = new String[] { "Akbar Seto Ramadhan (A11.2011.05937)", "Galuh Adjeng Sekarsari (A11.2011.05996)", "Izzi Abdul Salam S (A11.2011.05832)",
"M. Chair Ziaulahq (A11.2011.06280)", "Muhammad Risman N (A11.2011.06152)"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.main,TEAMWORK));
ListView listView = getListView();
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(),
((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
KEMUDIAN KITA TES APLIKASINYA
Tidak ada komentar:
Posting Komentar