0

Can we pass edittext values to gridview? If so, can you explain with example?

I checked and not able find anywhere in this site. I am new to android and java. so pls help me

nkarthek
  • 11
  • 1
  • 1
    Your question is not clear, what have you tried so far ? – amit singh Jan 15 '14 at 14:10
  • final ArrayList list = new ArrayList(); final ArrayAdapter listitems = new ArrayAdapter(MainActivity.this, android.R.layout.simple_list_item_1,list); gridview1.setAdapter(listitems); btn1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { String input = edittext1.getText().toString(); if(null!=input&&input.length()>0){ list.add(input); listitems.notifyDataSetChanged(); } } }); } – nkarthek Jan 15 '14 at 14:17
  • you are setting the adapter earlier, without adding anything to the list. And you are adding items in list on button click, why ? – amit singh Jan 15 '14 at 17:17

1 Answers1

0

You can do a GrisView Adapter custom adapter for gridview in android , in it you can have a parameter lets say editTextValue . In its constructor you will initialize this .In the activity with edit text you will have

       String value = editText.getText();
       MyCustomGridViewAdapter  gridView = new MyCustomGridViewAdapter   (param1 , param2....., value);
Community
  • 1
  • 1
Raluca Lucaci
  • 2,058
  • 3
  • 20
  • 37