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();
}
});
}
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);
}
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);
}
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);
}
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);
}
Aggregations