2012-02-03 16 views
1

私は2つのテキストビューと1つの行に1つのEditViewである1つのリストを持っています。私はこれらのtextviewsと実行時にeditviewをバインドし、今私はリストビュー内のedittextのいくつかの妥当性検査をしたいのですが、私のEditView IDはすべての行に対して同じです。マイコードは、ここでは、このリストビューでリストビュー内でAndroid EditTextの検証を行う方法は?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" 
android:paddingBottom="6dip" 
android:paddingTop="4dip" > 

<TextView 
    android:id="@+id/txt_Meter_Name" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:width="140dp" /> 

<TextView 
    android:id="@+id/txt_Previous" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:width="100dp" /> 

<EditText 
    android:id="@+id/ed_Current" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:imeOptions="actionNext|actionDone" 
    android:singleLine="true" 
    android:width="100dp" > 
</EditText> 

+0

「私EditView IDがすべての行で同じである、」それはほんの数EditViewsはない(のみ表示のもののための)すべての行... HTTPのために、存在してあなただけの問題ではありませんwww.youtube.com/watch?v=wDBM6wVEO70 – Selvin

答えて

0
You have two way for this. 
1. Using Custom Adapter 
2.As you are doing..but when you are selecting position then you need to get view id like 

lst.setOnTouchListener(new View.OnTouchListener() { 

    public boolean onTouch(View v, MotionEvent event) { 
     if(event.getAction() == MotionEvent.ACTION_MOVE){ 
      lst.scrollBy(0, 1); 
     } 
     return false; 
    } 
}); 

You should take operation on View v.This view will give you differnt id as it have. 
I will suggest you to use custom adapter if not resolved this way as you are doing. 
+0

私はそれを通過できるように、私にカスタネットアダプタの例を教えてもらえますか? –

+0

はいこれを待ってください... –

+0

list.setAdapter(new customadapter()); –

0

ビルドをbuindingイム

try { 
     json = new JSONObject(status); 
     getArray_Meter_Reading = new JSONArray(); 
     getArray_Meter_Reading = json.getJSONArray("meterReadings"); 

     myList = new ArrayList<HashMap<String, String>>(); 
     for (int i = 0; i < getArray_Meter_Reading.length(); i++) { 

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

      String meter_Name = getArray_Meter_Reading.getJSONObject(i) 
        .getString("MeterName").toString(); 

      String previous_Meter_Reading = getArray_Meter_Reading 
        .getJSONObject(i).getString("PrevMeterReading") 
        .toString(); 

      map.put("meterName", meter_Name); 
      map.put("previousMeterReading", previous_Meter_Reading); 

      myList.add(map); 

     } 

    } catch (JSONException e) { 

     e.printStackTrace(); 
    } 

    SimpleAdapter myAdapter = new SimpleAdapter(this, myList, 
      R.layout.meter_reading_list, new String[] { 
        "meterName", "previousMeterReading" }, new int[] { R.id.txt_Meter_Name, 
        R.id.txt_Previous}); 

    lst.setAdapter(myAdapter); 

    lst.setOnTouchListener(new View.OnTouchListener() { 

     public boolean onTouch(View v, MotionEvent event) { 
      if(event.getAction() == MotionEvent.ACTION_MOVE){ 
       lst.scrollBy(0, 1); 
      } 
      return false; 
     } 
    }); 

そして、私のXmlのレイアウトである

事前のおかげで、私の下手な英語のため申し訳ありません

あなたのHashMapを使用するカスタムアダプタ...

ListViewのビューで処理するときはいつでも、 ロジック の実装を処理するカスタムアダプタを作成し、その情報を必要に応じてビューに渡す必要があります。 //:

0
try this using custom adapter... 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
list = (ListView) findViewById(R.id.list); 

list.setAdapter(new customadapter()); 
} 

class customadapter extends BaseAdapter{ 

    public int getCount() { 
     // TODO Auto-generated method stub 
     return arraylist.size(); 
    } 

    public Object getItem(int position) { 
     // TODO Auto-generated method stub 
     return position; 
    } 

    public long getItemId(int position) { 
     // TODO Auto-generated method stub 
     return position; 
    } 

    public View getView(int postion, View convertView, ViewGroup parent) { 
     // TODO Auto-generated method stub 
     ViewHolder holder = null; 
     LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); 
     if (convertView == null) { 
      convertView = inflater.inflate(R.layout.readsggs_row, 
        null); 
      holder = new ViewHolder(); 
     }else 
     { 

       holder = (ViewHolder) convertView.getTag(); 

     } 
      //for (i = 0; i < DatabaseMethods.sggsbmid.size(); i++) { 
     convertView.setTag(holder); 
     if(postion%2==0) 
     { 
      convertView.setBackgroundColor(Color.parseColor("#A9BCF5")); 
     }else 
     { 
      convertView.setBackgroundColor(Color.parseColor("#ffffff")); 
     } 
     holder.textview = (TextView) convertView 
        .findViewById(R.id.text); 

     <///Like this text view you can use any view that you need////> 

     return convertView; 
    } 
    class ViewHolder { 
     TextView textview; 
    } 
} 
+0

問題がある場合は教えてください....私の作業コードと私はあなたがやっている。 –

関連する問題