データベースからのレコードを介して入力されるリスト ビューがあります。今、いくつかのレコードを表示するが、選択できないようにする必要があります。どうすればそれを達成できますか?
これが私のコードです
public class SomeClass extends ListActivity {
private static List<String> products;
private DataHelper dh;
public void onCreate(Bundle savedInstanceState) {
dh = new DataHelper(this);
products = dh.GetMyProducts(); /* Returns a List<String>*/
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.myproducts, products));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener( new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), ((TextView) arg1).getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
レイアウト ファイル myproducts.xml は次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="16sp">
</TextView>