첫 번째 위치에서 새 항목을 gridview에 어떻게 추가합니까? 그 후 첫 번째 위치에서 gridview에 새 항목을 추가하는 방법은 무엇입니까?
protected void showList() {
try {
JSONObject jsonObj = new JSONObject(myJSON);
peoples = jsonObj.getJSONArray(TAG_RESULTS);
for (int i = 0; i < peoples.length(); i++) {
JSONObject c = peoples.getJSONObject(i);
String userid = c.getString(Config.KEY_USERID);
String thumburl = c.getString(Config.KEY_THUMBURL);
HashMap<String, String> persons = new HashMap<String, String>();
persons.put(Config.KEY_USERID, userid);
persons.put(Config.KEY_THUMBURL, thumburl);
personList.add(persons);
}
GridView listview = (GridView) findViewById(R.id.gridview);
adapter = new ListViewAdapter(NewRetriveData.this, personList);
listview.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
나는 내가 동적으로의 GridView 1 위치에 배열 항목 쇼를 추가하고 싶지는 ArrayList의
GridView listview = (GridView) findViewById(R.id.gridview);
adapter = new ListViewAdapter(NewRetriveData.this, personList);
listview.setAdapter(null);
listview.setAdapter(adapter);
를 다시로드하고 동적으로 그 후
HashMap<String, String> persons = new HashMap<String, String>();
persons.put(Config.KEY_USERID, "sweety");
persons.put(Config.KEY_THUMBURL, "www.sweety.com/hello.jpg");
을 위해 ArrayList 새로운 항목을 추가하고있다.
에서 그것을 사용할 수 있습니다. –
http://stackoverflow.com/questions/20651946/how-to-set-the-first-item-in-gridview-with-default-value-and-populate-the-rest-o 여기를 참조하십시오. –
내 대답 확인 . –