我不能让ListView的项目我不、能让、项目、ListView

2023-09-04 03:15:10 作者:劳资独宠一方

我有两个TextView的在我的hola.xml文件,我想说明的是第一个(0)。谢谢

  TextView的T =(TextView中)findViewById(R.id.textViewNMAT1);
字符串富=((TextView中)((ViewGroup中)ARG1).getChildAt(0))的getText()的toString()。
t.se​​tText(富);
 

解决方案

更​​改为

  @覆盖
    公共无效onItemClick(适配器视图<> infoM,查看ARG1,INT职位,长_id)
    {
        TextView的T =(TextView中)findViewById(R.id.textViewNMAT1);
        字符串富=((TextView中)ARG1).getText()的toString()。

        t.se​​tText(富);
    }
 

第一个参数是保存适配器信息对象(微调的ListView ,等...),第二个参数查看这是点击(这里的TextView )。因此,获得这是在文本的TextView

ListView 部分Item不可选中

文档

I have two textview in my hola.xml file, I want to show is the first (0). thanks

TextView t = (TextView) findViewById(R.id.textViewNMAT1);
String foo = ((TextView)((ViewGroup) arg1).getChildAt(0)).getText().toString();
t.setText(foo);

解决方案

Change to

    @Override
    public void onItemClick(AdapterView<?> infoM, View arg1, int posicion, long _id)
    {
        TextView t = (TextView) findViewById(R.id.textViewNMAT1);
        String foo = ((TextView)arg1).getText().toString();

        t.setText(foo);
    }

the first param is the object that holds the Adapter info (Spinner, ListView, etc...) and the second param is the View which was clicked (here a TextView). So get the text which is in that TextView.

Docs