0

我工作的EditText位置上ListViewEditText inside.I已經在ListView。我是與得到的ListViewEditText位置面臨的問題各項目使用了四個EditText。以下是我的代碼。我能夠取得TextView的位置,但是在取得EditText的位置時我面臨問題。如何獲得在列表視圖

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


        myproductpercarton = (TextView) view.findViewById(R.id.txtorderamount); 
        final String ssss =(String) ((TextView) view.findViewById(R.id.txtorderamount)).getText();    
        mytotalprice = (TextView) view.findViewById(R.id.txtprice); 
        mm = (CheckBox) view.findViewById(R.id.mycheck); 
        mm.setFocusableInTouchMode(true); 
        mm.setFocusable(true); 
        mm2 = (CheckBox) view.findViewById(R.id.mynewcheck); 
        mm2.setFocusableInTouchMode(true); 
        mm2.setFocusable(true); 
        myorderprice = (EditText) view.findViewById(R.id.txtorderby); 
        myorderprice.setFocusableInTouchMode(true); 
        myorderprice.setFocusable(true); 
        mycartonno = (EditText) view.findViewById(R.id.txtordercarton); 
        mycartonno.setFocusableInTouchMode(true); 
        mycartonno.setFocusable(true); 


        myproductno = (EditText) view.findViewById(R.id.txtproduct); 
        myproductno.setFocusableInTouchMode(true); 
        myproductno.setFocusable(true); 

        myproductno.setOnClickListener(new View.OnClickListener() { 
         @Override 
         public void onClick(View v) { 


          String myprodpercart; 
          map = (HashMap<String, String>) getListView().getItemAtPosition(position); 
          HashMap<String, String> map2 = (HashMap<String, String>) getListView().getItemAtPosition(position); 
          HashMap<String, String> map3 = (HashMap<String, String>) getListView().getItemAtPosition(position); 


          double orderId4; 
          double mycarton2; 
          double mynewcart; 
          double myprodno2; 
          double mycartquantity; 
          double mytotal; 
          String mynoocarton; 
          double mynoocarton44; 
          int myprodno3;       
          String temp=mycartonno.getText().toString(); 
          String contents = mycartonno.getText().toString(); 
          orderId4 = new Double(map.get(TAG_PRODUCTPERCARTON)); 
          Log.d("MyOrderId :: ", String.valueOf(orderId4)); 
          mycartonprice2 = map.get(TAG_PRODUCTPERCARTON2); 
          Log.d("MyCartonPrice :: ", String.valueOf(mycartonprice2));        
          mynoocarton = mycartonno.getText().toString(); 
          mynoocarton44 = new Double(mycartonno.getText().toString()); 

          mycarton2 = new Double(mynoocarton); 
          mynewcart = new Double(mycartonprice2); 
          myprodno2 = new Double(orderId4 * mycarton2); 
          myprodno3 = new Integer((int) myprodno2); 
          mycartquantity = new Double(mycartonno.getText().toString()); 
          Log.d("MyCartonNo :: ", mycartonno.getText().toString()); 
          Log.d("MyCartonNo2 :: ",contents);        
          mytotal = new Double(mycartquantity * mynewcart); 
          String mynoocarton3 = String.valueOf(mynoocarton44);        
          String total = String.valueOf(mytotal); 
          String mm = String.valueOf(myprodno3);        
          mycartonno.setText(mynoocarton3); 
          myproductno.setText(mm); 
          mytotalprice.setText(total); 
          Toast.makeText(getActivity(), ssss + " " + mynewcart + "----" + mm + " " + total, 
            Toast.LENGTH_SHORT).show(); 

         } 
        }); 
        mydiscount = (EditText) view.findViewById(R.id.txtdiscount); 
        mydiscount.setFocusableInTouchMode(true); 
        mydiscount.setFocusable(true); 
       } 
      }); 
+0

是什麼問題?意味着你無法獲得職位? – Vickyexpert

+0

您的清單項目佈局的分享代碼 – LaurentY

+0

您面臨什麼「問題」? – jaibatrik

回答

0

我自己解決了這個問題,現在它的工作正常。我只是在另一個textviewsetOnClickListener內部有兩個新的edittext。我只是在setOnClickListener內添加了以下代碼。

TextView mynewtotal = (TextView) view.findViewById(R.id.txtprice); 
EditText mycartonprod = (EditText) view.findViewById(R.id.txtordercarton); 
mycartonprod.setFocusableInTouchMode(true); 
mycartonprod.setFocusable(true); 
EditText myprod = (EditText) view.findViewById(R.id.txtproduct); 
myprod.setFocusableInTouchMode(true); 
myprod.setFocusable(true);