0

は、これは私の.javaファイルです:row.xmlで私の活動は、すぐに私は実行するとFORCEのCLOSINGです..私はListActivityを使用し、カスタム・アダプターを作成している

public class List1 extends ListActivity { 
    /** Called when the activity is first created. */ 

    ListView lv1; 
    private ArrayList<Tree> m_orders; 
    private TreeAdapter m_adapter; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     getItems(); 
     this.m_adapter = new TreeAdapter(this, R.layout.row, m_orders); 
     setListAdapter(this.m_adapter); 


     } 
    public void getItems() 
     { 
      m_orders=new ArrayList<Tree>(); 
      Tree t=new Tree(); 
      t.setItemName("Document"); 
      m_orders.add(t); 

      t.setItemName("Address Book"); 
      m_orders.add(t); 

     } 

} 

     class TreeAdapter extends ArrayAdapter<Tree> 
    { 
    private ArrayList<Tree> it; 
     public TreeAdapter(Context context, int textViewResourceId,ArrayList<Tree> items) 
    { 
       super(context, textViewResourceId, items); 
       this.it=items; 
    } 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     View v = convertView; 
     if (v == null) { 
      LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      v = vi.inflate(R.layout.row, null); 

     } 

     Tree o = it.get(position); 

     if (o != null) { 
      TextView tt = (TextView) v.findViewById(R.id.toptext); 
      Button btn = (Button)v.findViewById(R.id.theButton); 
      if (tt != null) { 
       tt.setText("Name is " + o.getItemName()); 
      } 
      if(btn!=null){ 
       btn.setTag(o); 
       btn.setOnClickListener(new OnClickListener() { 
        @Override 
        public void onClick(View v) { 
        Tree o = (Tree)v.getTag(); 
        String message = o.getItemName() + " clicked"; 
         Toast.makeText(getContext(), message, Toast.LENGTH_LONG).show(); 
        } 
       }); 
      } 
     } 
     return v; 
    } 

} 

私は
のLinearLayoutを持っています
- >チェックボックス
- >ボタン
- main.xmlで>のTextView

私がやった
のLinearLayout
- > ListViewの
- >のTextView

私はLOGCATでこれを取得しています:
致命的な例外:
かもしれない活動COMPONENT.INFO

+0

stack traceとmain.xmlの内容があれば投稿できますか? –

+0

あなたの質問を編集し、あなたが含めることを選んだ1行だけではなく、 "FORCE CLOSE"に関連するスタックトレース全体を投稿してください。 – CommonsWare

+0

私はそれを固定しました...あなたの興味のためにとにかく..ありがとう – cooldeep

答えて

1

一つのことを開始することができませんリストアを行うxmlレイアウトにはandroid:id="@android:id/list"というListViewが含まれていなければなりませんが、main.xmlファイルとスタックトレースなしで問題があるかどうかは分かりません。

+0

計算に愚かな間違いがありました..私はそれを修正しました。どうもありがとう.. – cooldeep