0

在我的项目需要与编辑文本布局的ListView的Android布局的ListView

enter image description here

请建议我怎么能做出这种布局

在此先感谢

任何帮助表示赞赏

+0

[尝试在这里(https://www.google.com/search?q=create+custom+listview+android&oq=create+custom+listview+android&aqs = chrome..69i57j0l4.5527j0j7&的SourceID =铬&espv = 210&es_sm = 122&即= UTF-8)或(这里)(https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact = 8&VED = 0CCsQFjAA&URL = HTTP%3A%2F%2Fwww.vogella.com%2Ftutorials%2FAndroidListView%2Farticle.html&EI = HL4xU9u0HcT4yAH6t4GgDg&USG = AFQjCNEmKxSOQWTEdnIteMT1duTBuc2Xsg&SIG2 = -ckuSP7bOp2uaBynXYMhlw&BVM = bv.63587204,d.aWc)第一 – codeMagic

+0

参见本实施例中的http:// vikaskanani .wordpress.com/2011/7月27日/ android-可聚焦-的EditText-内部-列表视图/ –

回答

0

使用下面的代码。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_weight="1" 
    android:layout_height="fill_parent"> 

     <LinearLayout 
     android:id="@+id/mylinear" 
     android:layout_width="match_parent" 
     android:layout_weight="1" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 

     > 

    </LinearLayout> 

</ScrollView> 


    <LinearLayout 
     android:id="@+id/group4ff" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:id="@+id/vazgecff" 
      android:layout_width="0dp" 
      android:layout_weight=".30" 
      android:layout_height="wrap_content" 
      android:onClick="cagir" 
      android:text="vazgec" /> 

     <Button 
      android:id="@+id/kaydetff" 
      android:layout_width="0dp" 
      android:layout_weight=".70" 
      android:layout_height="wrap_content" 
      android:onClick="cagir" 
      android:text="kaydet" /> 
    </LinearLayout> 

</LinearLayout> 

Activity.java

public class Form3 extends Activity { 

LinearLayout[] llx ; 
TextView[] tx ; 
EditText[] ex ; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_form3); 

    DBHandler db = new DBHandler(this); 
    ArrayList<Siparis> listem = db.getSiparis(); 
    db.close(); 

    LinearLayout ll = (LinearLayout) findViewById(R.id.mylinear); 
    llx = new LinearLayout[listem.size()]; 
    tx = new TextView[listem.size()]; 
    ex = new EditText[listem.size()]; 

    for (int i = 0; i < listem.size(); i++) { 
     llx[i] = new LinearLayout(this); 
     tx[i] = new TextView(this); 
     ex[i] =new EditText(this); 
     tx[i].setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT,0.8f)); 
     ex[i].setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT,0.2f)); 
     tx[i].setText(listem.get(i).getMalzeme_adi()); 
     ex[i].setInputType(InputType.TYPE_CLASS_NUMBER); 
     llx[i].setId(i); 
     llx[i].setClickable(true); 
     final int j = i; 
     llx[i].setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       msg(tx[j].getText().toString()); 
      } 
     }); 

     llx[i].addView(tx[i]); 
     llx[i].addView(ex[i]); 

     ll.addView(llx[i]); 
    } 

} 


private void msg(String x){ 
    Toast.makeText(this, x, Toast.LENGTH_LONG).show(); 
} 

public void cagir(View view){ 
    switch (view.getId()) { 
    case R.id.kaydetff: 
     for (int i = 0; i < ex.length; i++) { 
      if(!ex[i].getText().toString().equals("")){ 
       Log.e(tx[i].getText().toString(),ex[i].getText().toString()); 
      } 
     } 
     break; 

    default: 
     break; 
    } 
} 
}