I am newbie with this language. I want to put the items in my gridview into the list view but i do not know how.
This is my code in MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView gv= (GridView) findViewById(R.id.gv);
Button b = (Button) findViewById(R.id.lv);
String[] items = new String[]{
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z"
};
b.setOnClickListener( new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent = new Intent("com.example.user.gridviewtolistview.Listview");
startActivity(intent);
}
}
);
final ArrayAdapter<String> gridViewArrayAdapter = new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1, items);
// Data bind GridView with ArrayAdapter (String Array elements)
gv.setAdapter(gridViewArrayAdapter);
}
This is the MainActivity UI
When I clicked on the button "Convert into Listview", it will go into another activity.
This is the Listview UI which looks like this:
I want to show the items in the gridview in the listview dynamically.