2013-05-04 23 views
1

在用戶單擊此列表項目後,我只顯示來自我的數據庫的三行中的三個詳細信息,所有細節都應該在列表視圖的其他活動中可見。我試過,但m到處一片空白的活動,而不是打開一個列表的.. ListViewDetails.java基於參數在列表視圖中顯示項目

listview.setOnItemClickListener(new OnItemClickListener() { 

     public void onItemClick(AdapterView<?> listView, View view, 
       int position, long id) { 
       // Get the cursor, positioned to the corresponding row in the result set 
       Cursor cursor = (Cursor) listView.getItemAtPosition(position); 

       // Get the state's capital from this row in the database. 
       int appno=cursor.getInt(cursor.getColumnIndexOrThrow("appln_no")); 


       Intent objintent=new Intent(getApplicationContext(),DisplayDetails.class); 
       objintent.putExtra("countryCode", countryCode); 
       startActivity(objintent); 

       } 
    }); 

這裏中號傳遞一個appno參數下一個意圖使與此相關的appno詳細信息顯示在DisplayDetails.java

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.listdisplay); 
     Intent intentobj=getIntent(); 
     int appno=intentobj.getIntExtra("appln_no", 0); 

     WayDataBase way=new WayDataBase(getApplicationContext()); 

     ArrayList<String> listvalues=way.getListDetails(appno); 

     if(listvalues.size()!=0) 
     { 
      ListView lv=getListView(); 
      ListAdapter adapter=new ArrayAdapter<String>(DisplayDetails.this, R.layout.view_animal_entry, R.id.animalName, listvalues); 
      lv.setAdapter(adapter); 

     } 
} 

但屏幕只是balnk .. 最新問題???請幫忙!謝謝!

回答

1

毒刃,

您已經賺得了變量的值從變量「COUNTRYCODE」「appno」,但設置值,而不是「appno」。

在你的DisplayDetails.java中,你試圖從變量「appln_no」中獲取它,這是不正確的。

如果我看看你的代碼,然後它似乎要appno值傳遞給另一個活動 所以應該保持這樣的:

ListViewDetails.java objintent.putExtra(「COUNTRYCODE」,appno );

DisplayDetails.java

INT appno = intentobj.getIntExtra( 「appln_no」, 「COUNTRYCODE」);

相關問題