Search in sources :

Example 1 with ArrayAdapter

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();
        }
    });
}
Also used : ListView(android.widget.ListView) RequestError(labs.anton.icenet.RequestError) ProgressDialog(android.app.ProgressDialog) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with ArrayAdapter

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);
}
Also used : Spinner(android.widget.Spinner) ArrayAdapter(android.widget.ArrayAdapter)

Example 3 with ArrayAdapter

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));
        }
    });
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 4 with ArrayAdapter

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);
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) ArrayList(java.util.ArrayList) ArrayAdapter(android.widget.ArrayAdapter)

Example 5 with ArrayAdapter

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);
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

ArrayAdapter (android.widget.ArrayAdapter)292 View (android.view.View)150 TextView (android.widget.TextView)99 ListView (android.widget.ListView)88 AdapterView (android.widget.AdapterView)87 ArrayList (java.util.ArrayList)52 Spinner (android.widget.Spinner)51 ViewGroup (android.view.ViewGroup)39 Intent (android.content.Intent)31 AutoCompleteTextView (android.widget.AutoCompleteTextView)29 Button (android.widget.Button)26 ImageView (android.widget.ImageView)26 ListAdapter (android.widget.ListAdapter)21 DialogInterface (android.content.DialogInterface)20 LayoutInflater (android.view.LayoutInflater)18 LinearLayout (android.widget.LinearLayout)18 Bundle (android.os.Bundle)17 RecyclerView (android.support.v7.widget.RecyclerView)17 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)17 EditText (android.widget.EditText)15