2011-08-10 17 views
0

こんにちは、私の古いコードは動作していますが、tablerowをクリックしているときに別のアクティティティが呼び出されますが、テーブルの行データは設定されませんが、最後の配列データはそのアクティビティに設定されます。タブロイドIDをアンドロイドで動的に取得する方法は?

最後の配列値を次の画面操作に設定することを意味します。

for (j = 0; j < dataListfeture.size(); j++) 
      { 

       HashMap<String, String> hm = new HashMap<String, String>(); 

       hm = dataListfeture.get(j); 

       final TableRow tblrow = new TableRow(MainScreen.this); 
       final View rowView = inflater.inflate(R.layout.featuredrow, null); 
       tblrow.setId(j); 
       tblrow.getId(); 



       featuredName = (TextView) rowView.findViewById(R.id.xxName); 
       featuredDistance = (TextView) rowView.findViewById(R.id.xxDistance); 
       featuredVeneType = (TextView) rowView.findViewById(R.id.xxVeneType); 
       featuredPhone = (TextView) rowView.findViewById(R.id.xxPhone); 
       featuredAddress = (TextView) rowView.findViewById(R.id.xxAddress); 

       Drawable image = ImageOperations(MainScreen.this, hm.get("url"), "image.jpg"); 

       featuredImage = (ImageView) rowView.findViewById(R.id.xxdImage); 
       featuredImage.setImageDrawable(image); 

       featuredName.setText("" + hm.get("name")); 
       featuredDistance.setText("" + hm.get("distance") + " mi"); 
       featuredVeneType.setText("" + hm.get("venuetype")); 
       featuredPhone.setText("" + hm.get("phonenumber")); 
       featuredAddress.setText("" + hm.get("address")); 


       mapnamelist = hm.get("name"); 
       mapvenuelist = hm.get("venuetype"); 
       mapothervenuelist = hm.get("othervenuetype"); 
       mapaddresslist= hm.get("address"); 
       mapcitylist= hm.get("city"); 
       mapstatelist= hm.get("state"); 


       tblrow.setOnClickListener(new OnClickListener() 
       { 

        @Override 
        public void onClick(View v) 
        { 

         final ProgressDialog progDailog = ProgressDialog.show(MainScreen.this, null, "Loading ....", true); 
         final Handler handler = new Handler() 
         { 
          public void handleMessage(Message msg) 
          { 
           System.out.println("search"); 

           Intent myIntent = new Intent(MainScreen.this, xxxxscreen.class); 
           startActivity(myIntent); 
           MainScreen.this.finish(); 
           progDailog.dismiss(); 

          } 
         }; 

         new Thread() 
         { 
          public void run() 
          { 
           try 
           { 

            System.out.println(); 


            handler.sendEmptyMessage(1); 

           } 
           catch (Exception e) 
           { 
            e.printStackTrace(); 
           } 
          } 
         }.start(); 

        } 
       }); 

答えて

1

IDのint配列を作成array_id[]とテーブルの行にIDを設定した後も

tblrow.setId(j); 
array_id[j] = j; 

好きなのonClickメソッドでarray_id[]にそのIDを追加しますが、これを行うと言う:

for(int i = 0;i< array_id.length;i++) 
{ 
    TableRow tbl_row = (TableRow) findViewById(i); 
    if(v.getId() == array_id[i]) 
    { 
     /** Perform your Operations */ 
    } 

} 
関連する問題