【问题标题】:Android Custom Listview view=null issueAndroid自定义列表视图视图=空问题
【发布时间】:2016-10-21 11:50:24
【问题描述】:

我有一个自定义列表视图和文本视图、复选框、编辑文本。我想迭代我的 listview 行并想要获取 textview、checkbox 和 edittext 值。当迭代到达页面末尾时,无法获取不可见的行小部件值并崩溃。我认为我必须自动向下滚动我的列表视图。我该如何解决这个问题?

注意:我有 12 行,但它在第 6 行后崩溃 cz 如果不向下滚动我的列表视图就看不到第 7 行。

这是我的代码:

public void onSave(View view) {
        ArrayList<String> olcum = new ArrayList<String>();
        ArrayList<String> orneklemebuyukluk = new ArrayList<String>();
        EditText et;
        CheckBox chx;
        TextView buyukluk;
        String nitel="0";
        for (int i = 0; i < list_olcum_view.getCount(); i++) {
            view = list_olcum_view.getChildAt(i);
            et = (EditText) view.findViewById(R.id.edt_olcum);
            chx=(CheckBox)view.findViewById(R.id.txt_orneklemenitel);
            olcum.add(et.getText().toString());

         }
}

【问题讨论】:

  • 请在下面检查我的代码
  • 你的适配器和你的getView()在哪里可以得到列表项的位置?看看how-to-get-listview-position
  • 请在我编辑您的问题并将您的代码放入其中时删除您的答案-

标签: java listview scrollview


【解决方案1】:
Note: I have 12 rows but it crashs after 6th row cz cannot see 7th row without scrolldown my listview.

public void onSave(View view) {
        ArrayList<String> olcum = new ArrayList<String>();
        ArrayList<String> orneklemebuyukluk = new ArrayList<String>();
        EditText et;
        CheckBox chx;
        TextView buyukluk;
        String nitel="0";
        for (int i = 0; i < list_olcum_view.getCount(); i++) {
            view = list_olcum_view.getChildAt(i);
            et = (EditText) view.findViewById(R.id.edt_olcum);
            chx=(CheckBox)view.findViewById(R.id.txt_orneklemenitel);
            olcum.add(et.getText().toString());

}
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多