Search in sources :

Example 16 with ArrayAdapter

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));
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) NavigationView(android.support.design.widget.NavigationView) Spinner(android.widget.Spinner) MainActivity(com.google.android.apps.flexbox.MainActivity) Menu(android.view.Menu) ArrayAdapter(android.widget.ArrayAdapter) FlakyTest(android.support.test.filters.FlakyTest) FlakyTest(android.support.test.filters.FlakyTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 17 with ArrayAdapter

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

Example 18 with ArrayAdapter

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

Example 19 with ArrayAdapter

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();
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) ActivityNotFoundException(android.content.ActivityNotFoundException) Button(android.widget.Button) File(java.io.File) ArrayAdapter(android.widget.ArrayAdapter)

Example 20 with ArrayAdapter

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());
}
Also used : ListView(android.widget.ListView) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView) ArrayAdapter(android.widget.ArrayAdapter) Test(org.junit.Test)

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