Search in sources :

Example 21 with Spinner

use of android.widget.Spinner in project recyclerview-animators by wasabeef.

the class AnimatorSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_animator_sample);
    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    if (getIntent().getBooleanExtra("GRID", true)) {
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    } else {
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }
    recyclerView.setItemAnimator(new SlideInLeftAnimator());
    final MainAdapter adapter = new MainAdapter(this, new ArrayList<>(Arrays.asList(data)));
    recyclerView.setAdapter(adapter);
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    for (Type type : Type.values()) {
        spinnerAdapter.add(type.name());
    }
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            recyclerView.setItemAnimator(Type.values()[position].getAnimator());
            recyclerView.getItemAnimator().setAddDuration(500);
            recyclerView.getItemAnimator().setRemoveDuration(500);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            adapter.add("newly added item", 1);
        }
    });
    findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            adapter.remove(1);
        }
    });
}
Also used : Spinner(android.widget.Spinner) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) GridLayoutManager(android.support.v7.widget.GridLayoutManager) SlideInLeftAnimator(jp.wasabeef.recyclerview.animators.SlideInLeftAnimator) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) Toolbar(android.support.v7.widget.Toolbar)

Example 22 with Spinner

use of android.widget.Spinner in project WordPress-Android by wordpress-mobile.

the class AddCategoryActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((WordPress) getApplication()).component().inject(this);
    setContentView(R.layout.add_category);
    if (savedInstanceState == null) {
        mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE);
    } else {
        mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE);
    }
    if (mSite == null) {
        ToastUtils.showToast(this, R.string.blog_not_found, ToastUtils.Duration.SHORT);
        finish();
        return;
    }
    loadCategories();
    final Button cancelButton = (Button) findViewById(R.id.cancel);
    final Button okButton = (Button) findViewById(R.id.ok);
    okButton.setOnClickListener(new Button.OnClickListener() {

        public void onClick(View v) {
            String categoryName = ((EditText) findViewById(R.id.category_name)).getText().toString();
            String categoryDesc = ((EditText) findViewById(R.id.category_desc)).getText().toString();
            Spinner categorySpinner = (Spinner) findViewById(R.id.parent_category);
            CategoryNode selectedCategory = (CategoryNode) categorySpinner.getSelectedItem();
            long parentId = (selectedCategory != null) ? selectedCategory.getCategoryId() : 0;
            if (categoryName.replaceAll(" ", "").equals("")) {
                //    Name field cannot be empty
                AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(AddCategoryActivity.this);
                dialogBuilder.setTitle(getResources().getText(R.string.required_field));
                dialogBuilder.setMessage(getResources().getText(R.string.cat_name_required));
                dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int whichButton) {
                    // Just close the window.
                    }
                });
                dialogBuilder.setCancelable(true);
                dialogBuilder.create().show();
            } else {
                Bundle bundle = new Bundle();
                TermModel newCategory = new TermModel();
                newCategory.setTaxonomy(TaxonomyStore.DEFAULT_TAXONOMY_CATEGORY);
                newCategory.setName(categoryName);
                newCategory.setDescription(categoryDesc);
                newCategory.setParentRemoteId(parentId);
                bundle.putSerializable(KEY_CATEGORY, newCategory);
                Intent mIntent = new Intent();
                mIntent.putExtras(bundle);
                setResult(RESULT_OK, mIntent);
                finish();
            }
        }
    });
    cancelButton.setOnClickListener(new Button.OnClickListener() {

        public void onClick(View v) {
            Intent mIntent = new Intent();
            setResult(RESULT_CANCELED, mIntent);
            finish();
        }
    });
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) Bundle(android.os.Bundle) Intent(android.content.Intent) View(android.view.View) CategoryNode(org.wordpress.android.models.CategoryNode) Button(android.widget.Button) TermModel(org.wordpress.android.fluxc.model.TermModel)

Example 23 with Spinner

use of android.widget.Spinner in project WordPress-Android by wordpress-mobile.

the class AddCategoryActivity method loadCategories.

private void loadCategories() {
    CategoryNode rootCategory = CategoryNode.createCategoryTreeFromList(mTaxonomyStore.getCategoriesForSite(mSite));
    ArrayList<CategoryNode> categoryLevels = CategoryNode.getSortedListOfCategoriesFromRoot(rootCategory);
    categoryLevels.add(0, new CategoryNode(0, 0, getString(R.string.none)));
    if (categoryLevels.size() > 0) {
        ParentCategorySpinnerAdapter categoryAdapter = new ParentCategorySpinnerAdapter(this, R.layout.categories_row_parent, categoryLevels);
        Spinner sCategories = (Spinner) findViewById(R.id.parent_category);
        sCategories.setAdapter(categoryAdapter);
    }
}
Also used : CategoryNode(org.wordpress.android.models.CategoryNode) Spinner(android.widget.Spinner)

Example 24 with Spinner

use of android.widget.Spinner in project Conversations by siacs.

the class StartConversationActivity method showCreateConferenceDialog.

private void showCreateConferenceDialog() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.create_conference);
    final View dialogView = getLayoutInflater().inflate(R.layout.create_conference_dialog, null);
    final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
    final EditText subject = (EditText) dialogView.findViewById(R.id.subject);
    populateAccountSpinner(this, mActivatedAccounts, spinner);
    builder.setView(dialogView);
    builder.setPositiveButton(R.string.choose_participants, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (!xmppConnectionServiceBound) {
                return;
            }
            final Account account = getSelectedAccount(spinner);
            if (account == null) {
                return;
            }
            Intent intent = new Intent(getApplicationContext(), ChooseContactActivity.class);
            intent.putExtra("multiple", true);
            intent.putExtra("show_enter_jid", true);
            intent.putExtra("subject", subject.getText().toString());
            intent.putExtra(EXTRA_ACCOUNT, account.getJid().toBareJid().toString());
            intent.putExtra(ChooseContactActivity.EXTRA_TITLE_RES_ID, R.string.choose_participants);
            startActivityForResult(intent, REQUEST_CREATE_CONFERENCE);
        }
    });
    builder.setNegativeButton(R.string.cancel, null);
    mCurrentDialog = builder.create();
    mCurrentDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) Account(eu.siacs.conversations.entities.Account) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView) SuppressLint(android.annotation.SuppressLint) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 25 with Spinner

use of android.widget.Spinner in project platform_frameworks_base by android.

the class SurfaceCompositionMeasuringActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    // Detect Andromeda devices by having free-form window management feature.
    mAndromeda = getPackageManager().hasSystemFeature(PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT);
    detectRefreshRate();
    // To layouts in parent. First contains list of Surfaces and second
    // controls. Controls stay on top.
    RelativeLayout rootLayout = new RelativeLayout(this);
    rootLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    CustomLayout layout = new CustomLayout(this);
    layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    Rect rect = new Rect();
    getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
    mWidth = rect.right;
    mHeight = rect.bottom;
    long maxMemoryPerSurface = roundToNextPowerOf2(mWidth) * roundToNextPowerOf2(mHeight) * 4;
    // Use 75% of available memory.
    int surfaceCnt = (int) ((getMemoryInfo().availMem * 3) / (4 * maxMemoryPerSurface));
    if (surfaceCnt < MIN_NUMBER_OF_SURFACES) {
        throw new RuntimeException("Not enough memory to allocate " + MIN_NUMBER_OF_SURFACES + " surfaces.");
    }
    if (surfaceCnt > MAX_NUMBER_OF_SURFACES) {
        surfaceCnt = MAX_NUMBER_OF_SURFACES;
    }
    LinearLayout controlLayout = new LinearLayout(this);
    controlLayout.setOrientation(LinearLayout.VERTICAL);
    controlLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mMeasureCompositionButton = createButton("Compositor speed.", controlLayout);
    mMeasureAllocationButton = createButton("Allocation speed", controlLayout);
    String[] pixelFomats = new String[PIXEL_FORMATS.length];
    for (int i = 0; i < pixelFomats.length; ++i) {
        pixelFomats[i] = getPixelFormatInfo(PIXEL_FORMATS[i]);
    }
    mPixelFormatSelector = new Spinner(this);
    ArrayAdapter<String> pixelFormatSelectorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, pixelFomats);
    pixelFormatSelectorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mPixelFormatSelector.setAdapter(pixelFormatSelectorAdapter);
    mPixelFormatSelector.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    controlLayout.addView(mPixelFormatSelector);
    mResultView = new TextView(this);
    mResultView.setBackgroundColor(0);
    mResultView.setText("Press button to start test.");
    mResultView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    controlLayout.addView(mResultView);
    mSystemInfoView = new TextView(this);
    mSystemInfoView.setBackgroundColor(0);
    mSystemInfoView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    controlLayout.addView(mSystemInfoView);
    for (int i = 0; i < surfaceCnt; ++i) {
        CustomSurfaceView view = new CustomSurfaceView(this, "Surface:" + i);
        // to mark as media overlay.
        if (i == 0) {
            view.setLayoutParams(new CustomLayout.LayoutParams(0, 0, mWidth, mHeight));
            view.setZOrderMediaOverlay(false);
        } else {
            // Z order of other layers is not predefined so make offset on x and reverse
            // offset on y to make sure that surface is visible in any layout.
            int x = i;
            int y = (surfaceCnt - i);
            view.setLayoutParams(new CustomLayout.LayoutParams(x, y, x + mWidth, y + mHeight));
            view.setZOrderMediaOverlay(true);
        }
        view.setVisibility(View.INVISIBLE);
        layout.addView(view);
        mViews.add(view);
    }
    rootLayout.addView(layout);
    rootLayout.addView(controlLayout);
    setContentView(rootLayout);
}
Also used : Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup) Spinner(android.widget.Spinner) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

Spinner (android.widget.Spinner)418 View (android.view.View)185 AdapterView (android.widget.AdapterView)146 TextView (android.widget.TextView)134 ArrayAdapter (android.widget.ArrayAdapter)132 EditText (android.widget.EditText)67 ArrayList (java.util.ArrayList)49 LinearLayout (android.widget.LinearLayout)48 Intent (android.content.Intent)45 Button (android.widget.Button)45 ImageView (android.widget.ImageView)43 CheckBox (android.widget.CheckBox)42 DialogInterface (android.content.DialogInterface)41 ViewGroup (android.view.ViewGroup)27 CompoundButton (android.widget.CompoundButton)27 RecyclerView (android.support.v7.widget.RecyclerView)26 LayoutInflater (android.view.LayoutInflater)26 ListView (android.widget.ListView)25 Test (org.junit.Test)23 Context (android.content.Context)19