2011-09-22 3 views
0

안녕하세요 아래 코드는 일부 코드입니다.하지만 디버깅 할 때 결코 onitemclicklisten 루틴에 도달 할 수 없습니까? 당신이프로그램이 onclick 수신 대기하지 않는 것 같습니다.

listContent.setOnItemClickListener(new OnItemClickListener() { 

에 중단 점을 설정하면 클릭하면

package sanderson.swords.mobilesales; 

import java.util.ArrayList; 
import java.util.HashMap; 

import android.app.Activity; 
import android.app.ListActivity; 
import android.database.Cursor; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.ListView; 
import android.widget.SimpleAdapter; 

import android.widget.AdapterView.OnItemClickListener; 

public class OrderProductSearch extends Activity { 
ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>(); 
    HashMap<String,String> item = new HashMap<String,String>(); 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    try{ 
     setContentView(R.layout.orderproducts); 
    } 
    catch (Exception e) { 
     // 
     String shaw=""; 
     shaw = e.getMessage(); 
    } 

    //Create view of the list where content will be stored 
    final ListView listContent = (ListView)findViewById(R.id.orderproductlistview); 

    //Set for fast scrolling 
    listContent.setFastScrollEnabled(true); 

    //Create instance of the database 
    final DbAdapter db = new DbAdapter(this); 

    //Open the Database and read from it 
    db.openToRead(); 

    //Routine to call all product sub groups from the database 
    final Cursor cursor = db.getAllSubGroupProduct(); 
    //Manages the cursor 
    startManagingCursor(cursor); 
    int i=0; 
    cursor.moveToFirst(); 
    while (cursor.getPosition() < cursor.getCount()) { 
     item.put("ProdName",cursor.getString(2)); 
     item.put("ProdSize", cursor.getString(3)); 
     item.put("ProdPack",cursor.getString(4)); 
     item.put("OrdQty","0"); 

     //list.add(item); 
     list.add(i, item); 
     item = new HashMap<String,String>(); 
     cursor.moveToNext(); 
     i = i + 1; 

    } 

    String[] from = new String[] {"ProdName", "ProdSize", "ProdPack", "OrdQty"}; 

    int[] to = new int[] { R.id.productlinerow, R.id.productlinerow2, R.id.productlinerow3, R.id.productlinerow4}; 
    SimpleAdapter notes = new SimpleAdapter(OrderProductSearch.this,list,R.layout.productlinerow,from,to);     
    listContent.setAdapter(notes); 


    //Close the database 
    db.close();  



    listContent.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView<?> parent, View view, 
       int position, long id) {  

      String neil = "test"; 

      neil = neil + "test"; 

     } 
     }); 


    } 




} 
+0

어떻게 그것이 onItemClick에 도착하지 않는지 확인하고 계십니까? –

+0

목록에 모든 항목이 표시됩니까? 리스너 루틴은 항목을 클릭 할 때만 호출됩니다. 실제로 항목이 있습니까? –

+0

안녕하세요 화면이 내 목록을 표시 아무 문제도 내가 edittext에 수량을 입력 할 수 있습니다. 마이크 내가 루틴에 몇 가지 간단한 코드를 배치하고 거기에 중단 점을 넣어 – shawrie

답변

0

클릭 수신기를 확인하는 가장 쉬운 방법은 일부 logcat 인쇄를 추가하는 것입니다 (예 :

listContent.setOnItemClickListener(new OnItemClickListener() { 
    public void onItemClick(AdapterView<?> parent, View view, 
      int position, long id) {  

     Log.d(TAG, "Click!"); 
    } 
    }); 
+0

시도했지만 시도해 본 적이 없습니까 ?? – shawrie

+0

잘 모르겠지만 대신 OnItemSelectedListener (http://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener.html)를 사용해보십시오. 적어도 시도하기 쉽습니다. :) – orjan

0

이 중단되지 않을 수도 있습니다.

String neil = "test"; 

및 디버깅에 중단 점을 설정하십시오.

+0

안녕 그것을 시도했지만 결코 거기에 도착 ??? – shawrie

+0

어쩌면 그것은 OnItemSelectedListener입니다. orjan이 아래에 언급 했으므로 – Jack

관련 문제