use of android.widget.ArrayAdapter in project IceNet by anton46.
the class JsonArrayActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ListView listView = (ListView) findViewById(R.id.list);
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Loading...");
dialog.show();
IceNet.connect().createRequest().get().pathUrl("/notes").fromJsonArray().mappingInto(Notes.class).execute("request_string", new RequestCallback<Notes>() {
@Override
public void onRequestSuccess(Notes notes) {
dialog.dismiss();
String[] values = new String[notes.size()];
for (int i = 0; i < notes.size(); i++) values[i] = notes.get(i).getTitle();
adapter = new ArrayAdapter<String>(JsonArrayActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
listView.setAdapter(adapter);
}
@Override
public void onRequestError(RequestError error) {
dialog.dismiss();
}
});
}
use of android.widget.ArrayAdapter in project cw-omnibus by commonsguy.
the class ContactSpinners method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner spin = (Spinner) findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);
ArrayAdapter<String> aa = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.options));
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
}
use of android.widget.ArrayAdapter in project UltimateAndroid by cymcsg.
the class SnackbarListViewSampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.snack_bar_activity_list_sample);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final ListView listView = (ListView) findViewById(android.R.id.list);
List<String> data = new ArrayList<String>();
for (int i = 0; i < 25; i++) {
data.add(String.format("Item %d", (i + 1)));
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, data);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SnackbarManager.show(Snackbar.with(SnackbarListViewSampleActivity.this).text(String.format("Item %d pressed", (position + 1))).actionLabel("Close").actionColor(Color.parseColor("#FF8A80")).duration(Snackbar.SnackbarDuration.LENGTH_LONG).attachToAbsListView(listView));
}
});
}
use of android.widget.ArrayAdapter in project cw-advandroid by commonsguy.
the class ActionModeDemo method performActions.
@SuppressWarnings("unchecked")
public boolean performActions(MenuItem item) {
ArrayAdapter<String> adapter = (ArrayAdapter<String>) getListAdapter();
SparseBooleanArray checked = getListView().getCheckedItemPositions();
switch(item.getItemId()) {
case R.id.cap:
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
int position = checked.keyAt(i);
String word = words.get(position);
word = word.toUpperCase();
adapter.remove(words.get(position));
adapter.insert(word, position);
}
}
return (true);
case R.id.remove:
ArrayList<Integer> positions = new ArrayList<Integer>();
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
positions.add(checked.keyAt(i));
}
}
Collections.sort(positions, Collections.reverseOrder());
for (int position : positions) {
adapter.remove(words.get(position));
}
getListView().clearChoices();
return (true);
}
return (false);
}
use of android.widget.ArrayAdapter in project cw-omnibus by commonsguy.
the class RowController method onTouch.
@Override
public boolean onTouch(View v, MotionEvent event) {
if ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0 && event.getAction() == MotionEvent.ACTION_DOWN) {
adapter.onChecked(position, true, true);
String[] items = itemView.getContext().getResources().getStringArray(R.array.popup);
ArrayAdapter<String> adapter = new ArrayAdapter<>(itemView.getContext(), android.R.layout.simple_list_item_1, items);
final ListPopupWindow popup = new ListPopupWindow(itemView.getContext());
popup.setAnchorView(itemView);
popup.setHorizontalOffset((int) event.getX());
popup.setVerticalOffset((int) event.getY() - itemView.getHeight());
popup.setAdapter(adapter);
popup.setWidth(measureContentWidth(itemView.getContext(), adapter));
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
((MainActivity) itemView.getContext()).playVideo(videoUri);
} else {
((MainActivity) itemView.getContext()).showLargeThumbnail(videoUri);
}
popup.dismiss();
}
});
popup.show();
return (true);
}
return (false);
}
Aggregations