我有一个应用程序,我们正在使用listview。当我们滚动时,我们没有得到列表项的值。显示错误强制关闭..任何人都可以帮助我。?
Click_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Resources res = getResources();
final String[] colors = res.getStringArray(R.array.Country);
final ListView l = (ListView) findViewById(R.id.listView1);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, colors);
l.setAdapter(adapter);
l.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
final ListView lsv=(ListView) arg0;
TextView tsv=(TextView) lsv.getChildAt(arg2);
String s=tsv.getText().toString();
TextView tv=(TextView) findViewById(R.id.test);
tv.setText(s);
new AlertDialog.Builder(context).setTitle(s)
.setMessage("Message")
.setNeutralButton("Close", new DialogInterface
.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing – it will close on its own
}
}).show();
}
});