Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 自定义ListView项目ID_Android_Android Listview - Fatal编程技术网

Android 自定义ListView项目ID

Android 自定义ListView项目ID,android,android-listview,Android,Android Listview,我正在尝试创建一个活动,用于设置我的应用程序的某些选项,我想使用具有3种不同类型视图的自定义listview,这是我的自定义listview的代码: public class CustomListAdapter extends ArrayAdapter<String>{ String[] text; Context context; CheckBox chkBox; public CustomListAdapter(Activity context,

我正在尝试创建一个活动,用于设置我的应用程序的某些选项,我想使用具有3种不同类型视图的自定义listview,这是我的自定义listview的代码:

public class CustomListAdapter extends ArrayAdapter<String>{
    String[] text;
    Context context;
    CheckBox chkBox;
    public CustomListAdapter(Activity context, String[] text){
        super(context, R.layout.layout_checkbox, text);
        this.text = text;
        this.context = context;
}
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        View single_row = null;
        if(position<4){
            LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            single_row = inflater.inflate(R.layout.layout_checkbox, null, true);
            TextView tv = (TextView)single_row.findViewById(R.id.textView1);
            tv.setText(text[position]);
            chkBox = (CheckBox)single_row.findViewById(R.id.checkBox1);
        }else{
            if(position<6){
                LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                single_row = inflater.inflate(R.layout.layout_phone, null, true);
                TextView tv = (TextView)single_row.findViewById(R.id.textView1);
                tv.setText(text[position]);
            }
        }
        if(position==6){
            LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            single_row = inflater.inflate(R.layout.layout_mail, null, true);
            TextView tv = (TextView)single_row.findViewById(R.id.textView1);
            tv.setText(text[position]);
        }
    return single_row;
    }
}
现在我想获得不同布局的输入小部件的ID,有没有办法做到这一点


谢谢你

你到底是什么意思??什么时候需要这些ID?当我需要访问输入小部件的值时,我需要活动中的ID,比如输入文本或复选框。一种方法是,可以对这些视图设置标记,然后使用findViewByTag查找它们
mList = (ListView)findViewById(R.Id.listView1);
CustomListAdapter adapter = new CustomListAdapter(this, texts);
mList.setAdapter(adapter);