2012-04-28 2 views
0

の子要素としてチェックボックスのステータスを取得できません:sendButtonクリックで、CheckBoxをチェックした後私は下の写真のような構造を使用しています私のコードでListView項目

enter image description here

を私はCheckBoxesのコードを以下のように読んでいますが、チェックされていません。 CheckboxName.isChecked()値はfalseですが、私のCheckBoxがチェックされている:私はいくつかを見つけた

try { 
       int nCount = NotebookList.getCount(); 
       LinearLayout v; 
       View vv; 
       CheckBox Available, Display, Demo; 
       v = (LinearLayout) findViewById(R.id.LinearNotebookList); 
       TextView _id, ID, Name; 
       for (int i = 0; i < nCount; i++) { 
        v = (LinearLayout) NotebookList.getAdapter().getView(i, null, 
          null); 
        _id = (TextView) v.findViewById(R.id.txt_Notebook_ID); 

        Available = (CheckBox) v 
          .findViewById(R.id.chkboxNotebookAvailable); 
        Display = (CheckBox) v.findViewById(R.id.chkboxNotebookDisplay); 
        Demo = (CheckBox) v.findViewById(R.id.chkboxNotebookDemo); 
        str_id = (String) _id.getText(); 

        if (Available.isChecked()) { 
         strAvailable = "YES"; 
        } else { 
         strAvailable = "NO"; 
        } 
        if (Display.isChecked()) { 
         strDisplay = "YES"; 
        } else { 
         strDisplay = "NO"; 
        } 
        if (Demo.isChecked()) { 
         strDemo = "YES"; 
        } else { 
         strDemo = "NO"; 
        } 

        rowID += db.insertAudit(Integer.parseInt(UserId), 
          Integer.parseInt(CityId), Integer.parseInt(OutletId), 
          0, dateTime, "002", Integer.parseInt(str_id), 
          strAvailable, strDisplay, strDemo, null, null, null, 
          null, null, null, null, null, null, null, Instance_Id) 
          + ","; 

       } 
      } catch (Exception ex) { 
       Toast.makeText(getApplicationContext(), ex.getMessage(), 
         Toast.LENGTH_SHORT).show(); 
      } 

レムへ

LayoutInflater inflater = (LayoutInflater) context 
       .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     View rowView = inflater.inflate(R.layout.desktop_list, parent, false); 

答えて

1

を知っ

は私がしてくださいYESの場合、フォローして何かを行うことができます助けることができることリストボックスで正しく動作するチェックボックスを取得するBaseAdapterクラスを使用する必要があります。

+0

私は何かできますか使用インフレータ LayoutInflaterインフレータ=(LayoutInflater)コンテキスト \t \t \t \t .getSystemService(Context.LAYOUT_INFLATER_SERVICE)。 \t \tビューrowView = inflater.inflate(R.layout.desktop_list、parent、false); – Trikaldarshi

+0

いいえ...このコードを見てくださいhttps://github.com/heepie/ListTemplate – codeskraps

関連する問題