我用textvIEw&创建了一个列表.使用holder的edittext …看起来像
TextvIEw Edittext--------------------------------- TextvIEw Edittext--------------------------------- TextvIEw Edittext---------------------------------
但我无法从每个Edittext获取数据……
任何人都可以帮助我..如何实现它…协助样本代码……
解决方法:
您好,尝试以下代码,您将达到您的要求,
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; }}
总结 以上是内存溢出为你收集整理的android – 从listview中获取edittext中的数据全部内容,希望文章能够帮你解决android – 从listview中获取edittext中的数据所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)