這個班怎麼了?在列表視圖中點擊尚未註冊,我試圖做一個記錄,但它不進入setItemOnClickListenerListView沒有迴應點擊
public class Chosen extends Activity{
SimpleCursorAdapter adapter;
String[] getResult;
Cursor c;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.chosen);
Intent i=getIntent();
Bundle extras=i.getExtras();
final TextView t=(TextView) findViewById(R.id.tv1);
int num=extras.getInt("category");
ArrayList al=new ArrayList<String>();
switch(num)
{
case 0:c=Splash.db.getSocial(Login.uname);break;
case 1:c=Splash.db.getMail(Login.uname);break;
case 2:c=Splash.db.getBank(Login.uname);break;
case 3:c=Splash.db.getMisc(Login.uname);break;
}
if(c.moveToFirst())
{
do
{
al.add(c.getString(1));
}while(c.moveToNext());
}
getResult=new String[al.size()];
al.toArray(getResult);
ListView lv=(ListView) findViewById(R.id.list);
lv.setClickable(true);
ArrayAdapter ad=new ArrayAdapter(this,R.layout.chosenitemlist,R.id.client,getResult);
lv.setAdapter(ad);
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long id) {
// TODO Auto-generated method stub
Log.w("akash", "in list item click");
t.setText("clicked");
Toast.makeText(getApplicationContext(), "hello", Toast.LENGTH_LONG).show();
}
});
}
}
非常感謝先生!我忘了提及我的行佈局也有一個按鈕,我把它的android:focusable設置爲false,並且它工作正常! – user962339