Search in sources :

Example 86 with ArrayAdapter

use of android.widget.ArrayAdapter in project AndroidTraining by mixi-inc.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mActivity = this;
    // ListViewに表示するデータを作成する
    ArrayList<String> list = new ArrayList<String>();
    for (int i = 0; i < 20; i++) {
        list.add("hoge" + i);
    }
    ListView listView = (ListView) findViewById(R.id.ListView);
    // android.R.layout.simple_list_item_1はAndroidで既に定義されているリストアイテムのレイアウトです
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_1, list);
    listView.setAdapter(adapter);
    // タップした時の動作を定義する
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Adapterからタップした位置のデータを取得する
            String str = (String) parent.getItemAtPosition(position);
            Toast.makeText(mActivity, str, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ArrayAdapter(android.widget.ArrayAdapter)

Example 87 with ArrayAdapter

use of android.widget.ArrayAdapter in project nucleus by konmik.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    check1 = (CheckedTextView) findViewById(R.id.check1);
    check2 = (CheckedTextView) findViewById(R.id.check2);
    check1.setText(MainPresenter.NAME_1);
    check2.setText(MainPresenter.NAME_2);
    check1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getPresenter().request(MainPresenter.NAME_1);
        }
    });
    check2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getPresenter().request(MainPresenter.NAME_2);
        }
    });
    ListView listView = (ListView) findViewById(R.id.listView);
    listView.setAdapter(adapter = new ArrayAdapter<>(this, R.layout.item));
    if (savedInstanceState == null)
        getPresenter().request(MainPresenter.DEFAULT_NAME);
}
Also used : ListView(android.widget.ListView) CheckedTextView(android.widget.CheckedTextView) View(android.view.View) ListView(android.widget.ListView) ArrayAdapter(android.widget.ArrayAdapter)

Example 88 with ArrayAdapter

use of android.widget.ArrayAdapter in project UltimateAndroid by cymcsg.

the class FloatingActionButtonDemo method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.floating_action_button_demo);
    FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.button_floating_action);
    floatingActionButton.attachToListView(getListView());
    ListAdapter listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.countries));
    getListView().setAdapter(listAdapter);
}
Also used : FloatingActionButton(com.marshalchen.common.ui.FloatingActionButtonWithListView.FloatingActionButton) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 89 with ArrayAdapter

use of android.widget.ArrayAdapter in project ChipsLayoutManager by BelooS.

the class TestActivity method initRv.

@UiThread
private void initRv() {
    adapter = createAdapter();
    RecyclerView.LayoutManager layoutManager = lmFactory.layoutManager(this);
    if (layoutManager == null)
        Log.e("initRv", "lm manager is null");
    rvTest.addItemDecoration(new SpacingItemDecoration(getResources().getDimensionPixelOffset(R.dimen.item_space), getResources().getDimensionPixelOffset(R.dimen.item_space)));
    positions = new LinkedList<>();
    for (int i = 0; i < items.size(); i++) {
        positions.add(String.valueOf(i));
    }
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    ArrayAdapter<String> spinnerAdapterMoveTo = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    spinnerPosition.setAdapter(spinnerAdapter);
    spinnerMoveTo.setAdapter(spinnerAdapterMoveTo);
    rvTest.setLayoutManager(layoutManager);
    //        rvTest.setLayoutManager(new LinearLayoutManager(this));
    rvTest.getRecycledViewPool().setMaxRecycledViews(0, 10);
    rvTest.getRecycledViewPool().setMaxRecycledViews(1, 10);
    rvTest.setAdapter(adapter);
}
Also used : SpacingItemDecoration(com.beloo.widget.chipslayoutmanager.SpacingItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) ArrayAdapter(android.widget.ArrayAdapter) UiThread(android.support.annotation.UiThread)

Example 90 with ArrayAdapter

use of android.widget.ArrayAdapter in project ChipsLayoutManager by BelooS.

the class ItemsFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    adapter = createAdapter(savedInstanceState);
    ChipsLayoutManager spanLayoutManager = ChipsLayoutManager.newBuilder(getContext()).setOrientation(ChipsLayoutManager.HORIZONTAL).build();
    rvTest.addItemDecoration(new SpacingItemDecoration(getResources().getDimensionPixelOffset(R.dimen.item_space), getResources().getDimensionPixelOffset(R.dimen.item_space)));
    positions = new LinkedList<>();
    for (int i = 0; i < items.size(); i++) {
        positions.add(String.valueOf(i));
    }
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    ArrayAdapter<String> spinnerAdapterMoveTo = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    spinnerPosition.setAdapter(spinnerAdapter);
    spinnerMoveTo.setAdapter(spinnerAdapterMoveTo);
    rvTest.setLayoutManager(spanLayoutManager);
    rvTest.getRecycledViewPool().setMaxRecycledViews(0, 10);
    rvTest.getRecycledViewPool().setMaxRecycledViews(1, 10);
    rvTest.setAdapter(adapter);
}
Also used : SpacingItemDecoration(com.beloo.widget.chipslayoutmanager.SpacingItemDecoration) ChipsLayoutManager(com.beloo.widget.chipslayoutmanager.ChipsLayoutManager) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

ArrayAdapter (android.widget.ArrayAdapter)309 View (android.view.View)154 TextView (android.widget.TextView)102 ListView (android.widget.ListView)92 AdapterView (android.widget.AdapterView)89 ArrayList (java.util.ArrayList)55 Spinner (android.widget.Spinner)51 ViewGroup (android.view.ViewGroup)40 Intent (android.content.Intent)33 AutoCompleteTextView (android.widget.AutoCompleteTextView)29 Button (android.widget.Button)26 ImageView (android.widget.ImageView)26 DialogInterface (android.content.DialogInterface)23 ListAdapter (android.widget.ListAdapter)21 RecyclerView (android.support.v7.widget.RecyclerView)18 LayoutInflater (android.view.LayoutInflater)18 LinearLayout (android.widget.LinearLayout)18 Bundle (android.os.Bundle)17 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)17 EditText (android.widget.EditText)15