从EditText上获取数据放置在列表视图 [英] getting data from edittext placed in listview
本文介绍了从EditText上获取数据放置在列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了TextView的和放列表;使用的EditText持有人......它看起来像
I created a list with textview & edittext using holder... it looks like
Textview Edittext
---------------------------------
Textview Edittext
---------------------------------
Textview Edittext
---------------------------------
但我不能让每个每个EDITTEXT数据... 任何一个可以帮助我..怎么实现的?帮助样品code ...
but I cant get the data from each every Edittext... can any one assist me.. how to achieve it... assist with sample code...
推荐答案
喜试试下面的$ C $立方米将达到您的要求,
Hi try the following code u will reach your requirement,
public class TestListView extends Activity {
ListView listView,listView2;
String[] titles = {"List 1 title1","List 1 title2","List 1 title3","List 1 title4","List 1 title5","List 1 title6","List 1 title7","List 1 title8","List 1 title9"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
listView = new ListView(this);
listView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
listView.setAdapter(new CustomListAdapetr(this, titles));
((LinearLayout)findViewById(R.id.mailLayout)).addView(listView);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
CustomView customView= (CustomView) arg0.getChildAt(arg2);
TextView textView = (TextView) customView.getChildAt(0);
Log.v("", ""+textView.getText());
}
});
}
public class CustomListAdapetr extends BaseAdapter{
private Context mContext;
private String[] list;
public CustomListAdapetr(Context context, String[] titles) {
mContext = context;
list = titles;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return list[position];
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
CustomView cv;
if (convertView == null) {
cv = new CustomView(mContext,""+list[position]);
}
else {
cv = (CustomView) convertView;
cv.setTitle(list[position]);
}
return cv;
}
}
private class CustomView extends LinearLayout {
public CustomView(Context context, String itemName) {
super(context);
this.setOrientation(HORIZONTAL);
// Here we build the child views in code. They could also have
// been specified in an XML file.
mTitle = new TextView(context);
mTitle.setText(itemName);
mTitle.setTextSize(25);
addView(mTitle, new LinearLayout.LayoutParams(200, LayoutParams.WRAP_CONTENT));
}
/** * Convenience method to set the title of a SpeechView */
public void setTitle(String title) {
mTitle.setText(title);
}
/** * Convenience method to set the dialogue of a SpeechView */
private TextView mTitle;
}
}
这篇关于从EditText上获取数据放置在列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文