我有一个字符串Canada@3@United States@14@Zambia@3@
需要在 gridView 上显示。
String[] numbers=newString.split("\\@");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, numbers);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(getApplicationContext(), ((TextView) v).getText(), Toast.LENGTH_SHORT).show();
}
});
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_marginTop="100dp"
android:numColumns="2"
android:textColor="#151B54" >
</GridView>
我只能看到白色的第一个条目(OnItemClickListener)对我有用,我只能看到吐司的形式。请纠正我