2013-04-26 2 views
0

를 온 클릭, 나는이 새로운 활동을 엽니 다 :TableRow가 나는 TableRow이 청취자

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:stretchColumns = "1" 
android:shrinkColumns = "1"> 

<TableRow 
    android:id="@+id/tableRow1" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:gravity="center_vertical"> 

       //content 
</TableRow> 

TableRow row1 = (TableRow) item.findViewById(R.id.tableRow1); 
    row1.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View arg0) { 
      // TODO Auto-generated method stub 

      Log.i("click detected", "yes"); 
      Bundle bundle = new Bundle(); 
      bundle.putString("noticeID",String.valueOf(data[pos].getID())); 
      bundle.putString("title",data[pos].getTitle()); 

      Intent newIntent = new Intent(activity, ReadNotice.class); 
      newIntent.putExtras(bundle); 
     } 
    }); 

로그가 기록하지만, 새로운 활동이 열려 있지, 내가 그리워 않았다 어떤 것?

+3

여기서는 startActivity (newIntent)입니다. ? –

답변

1

당신은 활동을 시작해야합니다. startActivity (newIntent);

+0

너무 바보 같은 실수! 감사! – user1256477

0
/************ if table row is dynamic then this method else method 2 is perfect************/ 
//if we want to applay listener on dynamic tablerow then use this 
//sure that perfect 
TablRowe tr = new TableRow(this); 
tr.setClickable(true); 
tr.setId(100);// if in loop then add 1 counter with 100 like (100+counter) at end count++ it 
tr.setOnClickListener(this); 
@Override 
    public void onClick(View v) 
{ 
     switch (v.getId()) 
     { 
     case 100: 
       Toast.makeText(getApplicationContext(), "100", Toast.LENGTH_SHORT).show(); 
      break; 

     case 101: 
      Toast.makeText(getApplicationContext(), "101", Toast.LENGTH_SHORT).show(); 
      break; 
} 
/************************** for simple like this ************************/ 
    TableRow row1 = (TableRow)findViewById(R.id.row1); 
row1.setonClickListener(this); 
public void onClick(View v) 
{ 
switch (v.getId()) 
     { 
     case R.id.row1: 
      // do work 
      break; 
      }   
}