use of android.widget.AdapterView in project coursera-android by aporter.
the class SpinnerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Get a reference to the Spinner
Spinner spinner = (Spinner) findViewById(R.id.spinner);
// Create an Adapter that holds a list of colors
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.colors, R.layout.dropdown_item);
// Set the Adapter for the spinner
spinner.setAdapter(adapter);
// Set an setOnItemSelectedListener on the spinner
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
// Display a Toast message indicating the currently selected
// item
Toast.makeText(parent.getContext(), "The color is " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
use of android.widget.AdapterView in project coursera-android by aporter.
the class GridFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mGridview.setAdapter(new ImageAdapter(getActivity(), mThumbNailIDs));
mGridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Intent intent = new Intent(getActivity(), ImageViewActivity.class);
intent.putExtra(EXTRA_RES_ID, (int) id);
startActivity(intent);
}
});
}
use of android.widget.AdapterView in project RecyclerViewItemAnimators by gabrielemariotti.
the class AnimationGridActivity method setupSpinner.
private void setupSpinner() {
Spinner spinner = (Spinner) findViewById(R.id.spinner);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.adapters, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
switch(position) {
case 0:
AlphaAnimatorAdapter animatorAdapter = new AlphaAnimatorAdapter(mAdapter, mRecyclerView);
mRecyclerView.setAdapter(animatorAdapter);
break;
case 1:
SlideInLeftAnimatorAdapter slideInLeftAnimationRecyclerViewAdapter = new SlideInLeftAnimatorAdapter(mAdapter, mRecyclerView);
mRecyclerView.setAdapter(slideInLeftAnimationRecyclerViewAdapter);
break;
case 2:
SlideInRightAnimatorAdapter slideInRightAnimatorAdapter = new SlideInRightAnimatorAdapter(mAdapter, mRecyclerView);
mRecyclerView.setAdapter(slideInRightAnimatorAdapter);
break;
case 3:
SlideInBottomAnimatorAdapter slideInBottomAnimatorAdapter = new SlideInBottomAnimatorAdapter(mAdapter, mRecyclerView);
mRecyclerView.setAdapter(slideInBottomAnimatorAdapter);
break;
case 4:
ScaleInAnimatorAdapter scaleInRecyclerViewAnimationAdapter = new ScaleInAnimatorAdapter(mAdapter, mRecyclerView);
mRecyclerView.setAdapter(scaleInRecyclerViewAnimationAdapter);
break;
case 5:
SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(mAdapter, mRecyclerView);
mRecyclerView.setAdapter(swingBottomInAnimationAdapter);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
use of android.widget.AdapterView in project RecyclerViewItemAnimators by gabrielemariotti.
the class ListActivity method setupSpinner.
private void setupSpinner() {
Spinner spinner = (Spinner) findViewById(R.id.spinner);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.animators, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
switch(position) {
case 0:
mRecyclerView.setItemAnimator(new SlideInOutLeftItemAnimator(mRecyclerView));
break;
case 1:
mRecyclerView.setItemAnimator(new SlideInOutRightItemAnimator(mRecyclerView));
break;
case 2:
mRecyclerView.setItemAnimator(new SlideInOutTopItemAnimator(mRecyclerView));
break;
case 3:
mRecyclerView.setItemAnimator(new SlideInOutBottomItemAnimator(mRecyclerView));
break;
case 4:
mRecyclerView.setItemAnimator(new ScaleInOutItemAnimator(mRecyclerView));
break;
case 5:
mRecyclerView.setItemAnimator(new SlideScaleInOutRightItemAnimator(mRecyclerView));
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
use of android.widget.AdapterView in project FBReaderJ by geometer.
the class ViewFilesContextMenuUtils method doShowHistoryContents.
/**
* Shows history contents to the user. He can clear all items.
*
* @param context
* {@link Context}
* @param fileProvider
* {@link IFileProvider}
* @param history
* {@link History} of {@link IFile}.
* @param currentLocation
* current location, will not be shown.
* @param listener
* will be notified after the user closed the dialog, or when the
* user selects an item.
*/
public static void doShowHistoryContents(final Context context, final IFileProvider fileProvider, final History<IFile> history, IFile currentLocation, final TaskListener listener) {
if (history.isEmpty())
return;
final AlertDialog _dialog = Dlg.newDlg(context);
// don't use Cancel button
_dialog.setButton(DialogInterface.BUTTON_NEGATIVE, null, (DialogInterface.OnClickListener) null);
_dialog.setIcon(android.R.drawable.ic_dialog_info);
_dialog.setTitle(R.string.afc_title_history);
List<IFileDataModel> data = new ArrayList<IFileDataModel>();
ArrayList<IFile> items = history.items();
for (int i = items.size() - 1; i >= 0; i--) {
IFile f = items.get(i);
if (f == currentLocation)
continue;
// check for duplicates
boolean duplicated = false;
for (int j = 0; j < data.size(); j++) {
if (f.equalsToPath(data.get(j).getFile())) {
duplicated = true;
break;
}
}
if (!duplicated)
data.add(new IFileDataModel(f));
}
final IFileAdapter _adapter = new IFileAdapter(context, data, FilterMode.DirectoriesOnly, null, false);
ListView listView = (ListView) LayoutInflater.from(context).inflate(R.layout.afc_listview_files, null);
listView.setBackgroundResource(0);
listView.setFastScrollEnabled(true);
listView.setAdapter(_adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (listener != null) {
_dialog.dismiss();
listener.onFinish(true, _adapter.getItem(position).getFile());
}
}
});
// OnItemClickListener
_dialog.setView(listView);
_dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.afc_cmd_clear), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
history.clear();
}
});
_dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (listener != null)
listener.onFinish(true, null);
}
});
_dialog.show();
}
Aggregations