アプリ作って海外移住

コピペプログラマーのメモ

array list








list_data.add(new Book(23, "","333hh"));
list_data.add(new Book(24, "子供とおでかけマップ","J520"));

//**************************リストクリック処理*************************
gv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {

GridView gv = (GridView)parent;
// String msg = (String)gv.getItemAtPosition(position);

//arraylist ポシション決定
Book user = list_data.get(position);
//そのポシションのデータ取得
              String msg =(user.getDay() + " ")+(user.getYotei() + " ");

             //そのポシションのデータ更新
user.setYotei("xxx");
//listview 更新
             adapter.notifyDataSetChanged();
Toast.makeText(MainActivity.this, "" + position+" "+msg, Toast.LENGTH_SHORT).show();
}





































import java.util.ArrayList; public class D1_1{ public static void main(String[] args){ ArrayList<User> arrayList = new ArrayList<User>(); arrayList.add(new Teacher("T999", "高橋")); arrayList.add(new Student("06JK000", "鈴木")); arrayList.add(new Student("06JK999", "伊藤")); for(int i = 0; i < arrayList.size(); i++){ User user = arrayList.get(i); System.out.print(user.getId() + " "); System.out.println(user.getName()); } } }

B3_7