【问题标题】:how to take the text in an array which come from a resource?如何获取来自资源的数组中的文本?
【发布时间】:2010-09-05 20:06:28
【问题描述】:

这是我的代码的一部分:

 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("") 中的 ""。 我只想从来自资源的列表视图中获取标题。 谢谢

【问题讨论】:

  • 我不知道你想做什么
  • 我有一个项目列表,我想获取一个项目的标题并将其放在 settitle(title) 中。对于每个项目。

标签: android string listview resources switch-statement


【解决方案1】:

我找到了:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-22
    • 2020-08-14
    • 1970-01-01
    • 2015-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-16
    相关资源
    最近更新 更多