This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeActivity extends Activity { | |
ArrayList<String> list_items; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_some); | |
this.list_items = new ArrayList<String>(); | |
this.list_items.add("one"); | |
this.list_items.add("two"); | |
this.list_items.add("three"); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
getMenuInflater().inflate(R.menu.some, menu); | |
return true; | |
} | |
private class ListAdapter extends BaseAdapter { | |
@Override | |
public int getCount() { | |
return list_items.size(); | |
} | |
@Override | |
public Object getItem(int position) { | |
return list_items.get(position); | |
} | |
@Override | |
public long getItemId(int position) { | |
return position; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
if (convertView == null) { | |
convertView = getLayoutInflater().inflate(R.layout.list_item, null); | |
} | |
String item = list_items.get(position); | |
// do something | |
return convertView; | |
} | |
} | |
} |
うん。やだ。