如何获取来自资源的数组中的文本?

时间:2010-09-05 20:06:29

标签: android string listview resources switch-statement

这是我的代码的一部分:

 public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
  TextView title_t = new TextView(this);
  title_t.setText("");
  String title = title_t.getText().toString();
  switch(position){



  case 0 : new AlertDialog.Builder(this).setTitle(title).setMessage("blah blah").setNeutralButton("close", new DialogInterface.OnClickListener() {

   @Override
   public void onClick(DialogInterface dialog, int which) {
    // TODO Auto-generated method stub

   }
  }).show();

我想用一个可以工作的东西替换title_t.setText(“”)中的“”。 我只想从列表视图中获取来自资源的标题。 感谢

1 个答案:

答案 0 :(得分:0)

我发现:

TextView str = new TextView(this);
    str.setText(parent.getItemAtPosition(position).toString());
    String title = str.getText().toString();

是我需要找到的parent.getItemAtPosition(position).toString()