use of android.widget.ArrayAdapter in project flexbox-layout by google.
the class MainActivityTest method testAlignContentSpinner.
@Test
@SuppressWarnings("unchecked")
@FlakyTest
public void testAlignContentSpinner() {
MainActivity activity = mActivityRule.getActivity();
FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
assertNotNull(flexboxLayout);
NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
assertNotNull(navigationView);
Menu menu = navigationView.getMenu();
final Spinner spinner = (Spinner) MenuItemCompat.getActionView(menu.findItem(R.id.menu_item_align_content));
ArrayAdapter<CharSequence> spinnerAdapter = (ArrayAdapter<CharSequence>) spinner.getAdapter();
final int spaceAroundPosition = spinnerAdapter.getPosition(activity.getString(R.string.space_around));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(spaceAroundPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_SPACE_AROUND));
final int stretchPosition = spinnerAdapter.getPosition(activity.getString(R.string.stretch));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
spinner.setSelection(stretchPosition);
}
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_STRETCH));
}
use of android.widget.ArrayAdapter in project grafika by google.
the class PlayMovieActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_movie);
mTextureView = (TextureView) findViewById(R.id.movie_texture_view);
mTextureView.setSurfaceTextureListener(this);
// Populate file-selection spinner.
Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner);
// Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout
// for the widget itself.
mMovieFiles = MiscUtils.getFiles(getFilesDir(), "*.mp4");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mMovieFiles);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner.
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
updateControls();
}
use of android.widget.ArrayAdapter in project grafika by google.
the class PlayMovieSurfaceActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_movie_surface);
mSurfaceView = (SurfaceView) findViewById(R.id.playMovie_surface);
mSurfaceView.getHolder().addCallback(this);
// Populate file-selection spinner.
Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner);
// Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout
// for the widget itself.
mMovieFiles = MiscUtils.getFiles(getFilesDir(), "*.mp4");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mMovieFiles);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner.
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(this);
updateControls();
}
use of android.widget.ArrayAdapter in project AndroidImageCrop by lorensiuswlt.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final String[] items = new String[] { "Take from camera", "Select from gallery" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_item, items);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Select Image");
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
//pick from camera
if (item == 0) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
mImageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "tmp_avatar_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
try {
intent.putExtra("return-data", true);
startActivityForResult(intent, PICK_FROM_CAMERA);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
} else {
//pick from file
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_FILE);
}
}
});
final AlertDialog dialog = builder.create();
Button button = (Button) findViewById(R.id.btn_crop);
mImageView = (ImageView) findViewById(R.id.iv_photo);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.show();
}
});
}
use of android.widget.ArrayAdapter in project robolectric by robolectric.
the class ShadowArrayAdapterTest method usesTextViewResourceIdToSetTextWithinListItemView.
@Test
public void usesTextViewResourceIdToSetTextWithinListItemView() throws Exception {
ListView parent = new ListView(RuntimeEnvironment.application);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(RuntimeEnvironment.application, R.layout.main, R.id.title, new String[] { "first value" });
View listItemView = arrayAdapter.getView(0, null, parent);
TextView titleTextView = (TextView) listItemView.findViewById(R.id.title);
assertEquals("first value", titleTextView.getText().toString());
}
Aggregations