我在ListView中有一个ListView活动,我写了一个问题。现在我只希望通过分别点击每个问题,它将从我创建的文本文件中检索一些选定的数据,并显示对其他一些活动的回答。
任何人都请帮助我并提供代码。
public class MainActivity4 extends AppCompatActivity implements AdapterView.OnItemClickListener {
String[] name={"Tell me about yourself ?"
,"Describe yourself in one word ?",
"Why did you leave your last job ?",
"What is your strength"};
ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity4_main);
lv=(ListView)findViewById(R.id.listView);
ArrayAdapter adapter =new ArrayAdapter(this,android.R.layout.simple_list_item_1,name);
lv.setAdapter(adapter);
lv.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(), parent.getItemAtPosition(position)+"", Toast.LENGTH_LONG).show();
}
}