Example usage for android.text InputType TYPE_TEXT_FLAG_MULTI_LINE

List of usage examples for android.text InputType TYPE_TEXT_FLAG_MULTI_LINE

Introduction

In this page you can find the example usage for android.text InputType TYPE_TEXT_FLAG_MULTI_LINE.

Prototype

int TYPE_TEXT_FLAG_MULTI_LINE

To view the source code for android.text InputType TYPE_TEXT_FLAG_MULTI_LINE.

Click Source Link

Document

Flag for #TYPE_CLASS_TEXT : multiple lines of text can be entered into the field.

Usage

From source file:org.lol.reddit.activities.PostSubmitActivity.java

private void setHint() {
    if (typeSpinner.getSelectedItem().equals("Link")) {
        textEdit.setHint("URL"); // TODO string
        textEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
        textEdit.setSingleLine(true);//  w  ww . ja v a 2  s.  c o  m
    } else {
        textEdit.setHint("Self Text"); // TODO string
        textEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
        textEdit.setSingleLine(false);
    }
}

From source file:bander.notepad.NoteEditAppCompat.java

@Override
protected void onResume() {
    super.onResume();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    // Font size//from w  w  w  .  java  2  s.c  o  m
    float textSize = Float.valueOf(preferences.getString("textSize", "16"));
    mBodyText.setTextSize(textSize);
    // Monospace font
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    boolean typeface = settings.getBoolean("typeface", true);
    if (typeface) {
        Typeface font = Typeface.MONOSPACE;
        mBodyText.setTypeface(font);
    } else {
        mBodyText.setTypeface(Typeface.SANS_SERIF);
    }
    // Auto-correct
    boolean input = preferences.getBoolean("inputType", true);
    if (input) {
        // AutoCorrect on
        mBodyText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE);
    } else {
        // AutoCorrect off
        mBodyText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    }

    Cursor cursor = getContentResolver().query(mUri, PROJECTION, null, null, null);
    Note note = Note.fromCursor(cursor);
    cursor.close();

    if (note != null) {
        if (mOriginalNote == null)
            mOriginalNote = note;
        mBodyText.setTextKeepState(note.getBody());

        Boolean rememberPosition = preferences.getBoolean("rememberPosition", true);
        if (rememberPosition) {
            mBodyText.setSelection(note.getCursor());
            mBodyText.scrollTo(0, note.getScrollY());
        }
    }
}

From source file:org.cafemember.messenger.mytg.fragments.TransfareActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    context = getContext();/*from  www . j a  v a 2s .  co  m*/
    //        View layout = inflater.inflate(R.layout.channels_layout, null);
    /*this.context = context;
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("MenuTransfare", R.string.MenuTransfare));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
    @Override
    public void onItemClick(int id) {
        if (id == -1) {
            finishFragment();
        } else if (id == done_button) {
            saveName();
        }else if (id == contact_button) {
            getContacts();
        }
    }
    });
            
    ActionBarMenu menu = actionBar.createMenu();
    contactsButton = menu.addItemWithWidth(contact_button, R.drawable.user_profile, AndroidUtilities.dp(56));
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
    */

    LinearLayout fragmentView = new LinearLayout(context);
    ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
    TextView ruleTextView = new TextView(context);
    ruleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    ruleTextView.setTextColor(0xff212121);
    ruleTextView.setGravity(Gravity.RIGHT);
    //        ruleTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("ShareText", R.string.ShareText)));
    ruleTextView.setText(LocaleController.getString("transfare_rule", R.string.transfare_rule));
    ((LinearLayout) fragmentView).addView(ruleTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 24, 10, 24, 30));

    phoneField = new EditText(context);
    phoneField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    phoneField.setHintTextColor(0xff979797);
    phoneField.setTextColor(0xff212121);
    phoneField.setMaxLines(1);
    phoneField.setLines(1);
    phoneField.setGravity(Gravity.RIGHT);
    phoneField.setPadding(0, 0, 0, 0);
    phoneField.setSingleLine(true);
    phoneField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    phoneField.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_MULTI_LINE
            | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    phoneField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    phoneField.setHint(LocaleController.getString("TransfareUserHint", R.string.TransfareUserHint));
    AndroidUtilities.clearCursorDrawable(phoneField);

    amountField = new EditText(context);
    amountField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    amountField.setHintTextColor(0xff979797);
    amountField.setTextColor(0xff212121);
    amountField.setMaxLines(1);
    amountField.setGravity(Gravity.RIGHT);
    amountField.setLines(1);
    amountField.setPadding(0, 0, 0, 0);
    amountField.setSingleLine(true);
    amountField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    amountField.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_MULTI_LINE
            | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    amountField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    amountField.setHint(LocaleController.getString("TransfareAmountHint", R.string.TransfareAmountHint));
    AndroidUtilities.clearCursorDrawable(amountField);

    phoneField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
                doneButton.performClick();
                return true;
            }
            return false;
        }
    });

    ((LinearLayout) fragmentView).addView(phoneField,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));

    checkTextView = new TextView(context);
    checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    checkTextView.setGravity(Gravity.RIGHT);
    ((LinearLayout) fragmentView).addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 12, 24, 0));

    Button button = new Button(context);

    button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    button.setTextColor(0xff6d6d72);
    button.setGravity(Gravity.CENTER);
    TextView helpTextView = new TextView(context);
    helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    helpTextView.setTextColor(0xff6d6d72);
    helpTextView.setGravity(Gravity.RIGHT);
    helpTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("RefHelp", R.string.RefHelp)));
    button.setText("");
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveName();
        }
    });
    ((LinearLayout) fragmentView).addView(helpTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 10, 24, 0));
    ((LinearLayout) fragmentView).addView(amountField,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));
    ((LinearLayout) fragmentView).addView(button,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 24, 24, 24, 0));

    /*View v = LayoutInflater.from(context).inflate(R.layout.transfare_type, null);
    typeJoin = (RadioButton)v.findViewById(R.id.joinRadio);
    typeView = (RadioButton)v.findViewById(R.id.viewRadio);
    ((LinearLayout) fragmentView).addView(v, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));*/
    phoneField.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            checkUserName(phoneField.getText().toString(), false);
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });

    checkTextView.setVisibility(View.GONE);
    FontManager.instance().setTypefaceImmediate(fragmentView);

    return fragmentView;
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

public View buildInput(Attribute attribute, ViewGroup parent) {
    Record record = model.getRecord();/*from  w  w w .  j  a  v  a2 s  .co  m*/
    View view;

    switch (attribute.getType()) {
    case STRING:
        view = buildEditText(InputType.TYPE_CLASS_TEXT, parent);
        break;
    case INTEGER:
    case NUMBER:
        view = buildEditText(InputType.TYPE_CLASS_NUMBER, parent);
        break;
    case DECIMAL:
    case ACCURACY:
        view = buildEditText(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL, parent);
        break;
    case MULTI_SELECT:
    case POINT_SOURCE:
    case STRING_WITH_VALID_VALUES:
        view = buildSpinner(attribute, parent);
        break;
    case CATEGORIZED_MULTI_SELECT:
        view = buildCategorizedSpinner(attribute, parent);
        break;
    case NOTES:
        view = buildEditText(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE, parent);
        break;
    case WHEN:
        view = buildDatePicker(attribute, record, parent);
        break;
    case DWC_TIME:
        view = buildTimePicker(attribute, record, parent);
        break;
    case SPECIES_P:
        view = buildSpeciesPicker(attribute, parent);
        break;
    case POINT:
        view = buildLocationPicker(attribute, parent);
        break;
    case IMAGE:
        view = buildImagePicker(attribute, parent);
        break;
    case SINGLE_CHECKBOX:
        view = buildSingleCheckbox(attribute, parent);
        break;
    case MULTI_CHECKBOX:
        view = buildMultiSpinner(attribute, parent);
        break;
    default:
        view = buildEditText(InputType.TYPE_CLASS_TEXT, parent);
        break;
    }
    return view;
}

From source file:id.zelory.tanipedia.activity.TanyaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tanya);
    toolbar = (Toolbar) findViewById(R.id.anim_toolbar);
    setSupportActionBar(toolbar);//from  w  ww . j ava 2  s. co m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("Tanya Tani");

    animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow);
    fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin);

    drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer);
    setUpNavDrawer();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.getMenu().getItem(2).setChecked(true);
    TextView nama = (TextView) navigationView.findViewById(R.id.nama);
    nama.setText(PrefUtils.ambilString(this, "nama"));
    TextView email = (TextView) navigationView.findViewById(R.id.email);
    email.setText(PrefUtils.ambilString(this, "email"));
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            menuItem.setChecked(true);
            drawerLayout.closeDrawers();
            Intent intent;
            switch (menuItem.getItemId()) {
            case R.id.cuaca:
                intent = new Intent(TanyaActivity.this, CuacaActivity.class);
                break;
            case R.id.berita:
                intent = new Intent(TanyaActivity.this, BeritaActivity.class);
                break;
            case R.id.tanya:
                return true;
            case R.id.harga:
                intent = new Intent(TanyaActivity.this, KomoditasActivity.class);
                break;
            case R.id.logout:
                PrefUtils.simpanString(TanyaActivity.this, "nama", null);
                intent = new Intent(TanyaActivity.this, LoginActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                return true;
            case R.id.tentang:
                intent = new Intent(TanyaActivity.this, TentangActivity.class);
                startActivity(intent);
                return true;
            default:
                return true;
            }
            startActivity(intent);
            finish();
            return true;
        }
    });

    recyclerView = (RecyclerView) findViewById(R.id.scrollableview);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.addOnScrollListener(new MyRecyclerScroll() {
        @Override
        public void show() {
            fab.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
        }

        @Override
        public void hide() {
            fab.animate().translationY(fab.getHeight() + fabMargin)
                    .setInterpolator(new AccelerateInterpolator(2)).start();
        }
    });

    tanyaGambar = (ImageView) findViewById(R.id.tanya_gambar);
    tanyaGambar.setVisibility(View.GONE);
    fab = (FrameLayout) findViewById(R.id.myfab_main);
    fab.setVisibility(View.GONE);
    fabBtn = (ImageButton) findViewById(R.id.myfab_main_btn);
    View fabShadow = findViewById(R.id.myfab_shadow);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fabShadow.setVisibility(View.GONE);
        fabBtn.setBackground(getDrawable(R.drawable.ripple_accent));
    }

    fabBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new MaterialDialog.Builder(TanyaActivity.this).title("TaniPedia").content("Kirim Pertanyaan")
                    .inputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_CLASS_TEXT)
                    .input("Ketik pertanyaan anda disini!", null, false, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            try {
                                pertanyaan = URLEncoder.encode(input.toString(), "UTF-8");
                                new KirimSoal().execute();
                            } catch (UnsupportedEncodingException e) {
                                Snackbar.make(fabBtn, "Terjadi kesalahan, silahkan coba lagi!",
                                        Snackbar.LENGTH_LONG).show();
                                e.printStackTrace();
                            }
                        }
                    }).positiveColorRes(R.color.primary_dark).positiveText("Kirim")
                    .cancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {

                        }
                    }).negativeColorRes(R.color.primary_dark).negativeText("Batal").show();
        }
    });

    fabButton = (FabButton) findViewById(R.id.determinate);
    fabButton.showProgress(true);
    new DownloadData().execute();
    fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fabButton.showProgress(true);
            new DownloadData().execute();
        }
    });
}

From source file:gov.in.bloomington.georeporter.fragments.ReportFragment.java

/**
 * Inflates the appropriate view for each datatype
 * //from   w ww. j  a v a 2s  . com
 * @param attribute
 * @param savedInstanceState
 * @return
 * View
 */
private View loadViewForAttribute(JSONObject attribute, Bundle savedInstanceState) {
    LayoutInflater inflater = getLayoutInflater(savedInstanceState);
    String datatype = attribute.optString(Open311.DATATYPE, Open311.STRING);

    if (datatype.equals(Open311.STRING) || datatype.equals(Open311.NUMBER) || datatype.equals(Open311.TEXT)) {
        View v = inflater.inflate(R.layout.list_item_report_attributes_string, null);
        EditText input = (EditText) v.findViewById(R.id.input);

        if (datatype.equals(Open311.NUMBER)) {
            input.setInputType(InputType.TYPE_CLASS_NUMBER);
        }
        if (datatype.equals(Open311.TEXT)) {
            input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
        }
        return v;
    } else if (datatype.equals(Open311.DATETIME)) {
        View v = inflater.inflate(R.layout.list_item_report_attributes_datetime, null);
        TextView input = (TextView) v.findViewById(R.id.input);
        input.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                SherlockDialogFragment picker = new DatePickerDialogFragment(v);
                picker.show(getActivity().getSupportFragmentManager(), "datePicker");
            }
        });
        return v;
    } else if (datatype.equals(Open311.SINGLEVALUELIST) || datatype.equals(Open311.MULTIVALUELIST)) {
        JSONArray values = attribute.optJSONArray(Open311.VALUES);
        int len = values.length();

        if (datatype.equals(Open311.SINGLEVALUELIST)) {
            View v = inflater.inflate(R.layout.list_item_report_attributes_singlevaluelist, null);
            RadioGroup input = (RadioGroup) v.findViewById(R.id.input);
            for (int i = 0; i < len; i++) {
                JSONObject value = values.optJSONObject(i);
                RadioButton button = (RadioButton) inflater.inflate(R.layout.radiobutton, null);
                button.setText(value.optString(Open311.KEY));
                input.addView(button);
            }
            return v;
        } else if (datatype.equals(Open311.MULTIVALUELIST)) {
            View v = inflater.inflate(R.layout.list_item_report_attributes_multivaluelist, null);
            LinearLayout input = (LinearLayout) v.findViewById(R.id.input);
            for (int i = 0; i < len; i++) {
                JSONObject value = values.optJSONObject(i);
                CheckBox checkbox = (CheckBox) inflater.inflate(R.layout.checkbox, null);
                checkbox.setText(value.optString(Open311.KEY));
                input.addView(checkbox);
            }
            return v;
        }
    }
    return null;
}

From source file:edumsg.edumsg_android_app.MainActivity.java

/**
 *
 * The onCreate method first retrieves the sessionId and username from the parent {@link android.content.Intent},
 * which is either created from a {@link LoginFragment} or a {@link RegisterFragment}. Afterwards,
 * it configures the action bar and performs view look-ups for the action bar buttons, followed
 * by setting the onClick listeners for the action bar buttons. Finally, it initializes the
 * properties, sets the onRefresh listener for the swipe refresh layout, and calls the method
 * {@link MainActivity#getFeed()}./*from  w w  w .j  a va2 s.c  o m*/
 *
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sessionId = getIntent().getExtras().getString("sessionId");
    username = getIntent().getExtras().getString("username");
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    final ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.menu_main, null);
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(actionBarLayout);
    ImageButton homeButton = ButterKnife.findById(actionBarLayout, R.id.btn_home);
    final ImageButton searchButton = ButterKnife.findById(actionBarLayout, R.id.btn_search);
    ImageButton createButton = ButterKnife.findById(actionBarLayout, R.id.btn_create);
    ImageButton navButton = ButterKnife.findById(actionBarLayout, R.id.btn_nav);

    final ViewGroup searchLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.menu_search, null);
    final SearchView searchView = ButterKnife.findById(searchLayout, R.id.search);
    final ImageButton backBtn = ButterKnife.findById(searchLayout, R.id.btn_back);

    homeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });

    searchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            actionBar.setCustomView(searchLayout);
            SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
            searchView.setSearchableInfo(searchManager
                    .getSearchableInfo(new ComponentName(MainActivity.this, SearchResultsActivity.class)));
            searchView.setQuery("", false);
            searchView.setIconified(false);
            searchView.setFocusable(true);
            searchView.requestFocusFromTouch();
        }
    });

    backBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            actionBar.setCustomView(actionBarLayout);
            InputMethodManager imm = (InputMethodManager) getApplicationContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(
                    MainActivity.this.getWindow().getDecorView().getRootView().getWindowToken(), 0);
        }
    });

    createButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

            final EditText input = new EditText(MainActivity.this);
            input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
            input.setLines(4);
            input.setSingleLine(false);
            input.setBackgroundDrawable(null);
            builder.setView(input);
            builder.setPositiveButton("Tweet", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    createTweet(input.getText().toString());
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            final AlertDialog dialog = builder.create();

            dialog.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialogInterface) {
                    Button posBtn = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
                    posBtn.setBackgroundColor(cPrimary);
                    posBtn.setTextColor(Color.WHITE);
                    final float scale = getApplicationContext().getResources().getDisplayMetrics().density;
                    int pixels = (int) (10 * scale + 0.5f);
                    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    layoutParams.setMargins(0, 0, pixels, 0);
                    posBtn.setLayoutParams(layoutParams);
                    Button negBtn = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
                    negBtn.setBackgroundColor(cPrimary);
                    negBtn.setTextColor(Color.WHITE);
                }
            });
            dialog.show();
        }
    });

    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FragmentManager fragmentManager = getSupportFragmentManager();
            List<Fragment> fragments = fragmentManager.getFragments();
            if (fragments != null) {
                for (Fragment fragment : fragments) {
                    if (fragment instanceof NavigationFragment)
                        return;
                }
            }
            NavigationFragment navigationFragment = new NavigationFragment();
            //                Bundle bundle = new_user Bundle();
            //                bundle.putInt("userId", userId);
            //                mainActivityFragment.setArguments(bundle);
            fragmentManager.beginTransaction().add(android.R.id.content, navigationFragment)
                    .addToBackStack("nav").commit();
            //                logout();
            //                launchMessages();
            //                Intent intent = new_user Intent(MainActivity.this, ProfileActivity.class);
            //                intent.putExtra("username", getUsername());
            //                intent.putExtra("name", getName());
            //                intent.putExtra("avatar_url", getAvatar_url());
            //                intent.putExtra("bio", getBio());
            //                intent.putExtra("creatorId", getUserId());
            //                intent.putExtra("userId", getUserId());
            //                startActivity(intent);
        }
    });

    recyclerView.setHasFixedSize(true);
    final float scale = getApplicationContext().getResources().getDisplayMetrics().density;
    int pixels = (int) (160 * scale + 0.5f);
    Paint paint = new Paint();
    paint.setStrokeWidth(3.0f);
    paint.setColor(Color.rgb(220, 220, 220));
    paint.setAntiAlias(true);
    recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).paint(paint).build());
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);

    tweetObjects = new ArrayList<>();
    rvAdapter = new RVAdapter(this, tweetObjects, sessionId);
    recyclerView.setAdapter(rvAdapter);

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            tweetObjects.clear();
            getFeed();
        }
    });

    getFeed();
}

From source file:org.cocos2dx.lib.Cocos2dxEditBoxDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000));

    LinearLayout layout = new LinearLayout(mParentActivity);
    layout.setOrientation(LinearLayout.VERTICAL);

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);

    mTextViewTitle = new TextView(mParentActivity);
    LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10);
    mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    layout.addView(mTextViewTitle, textviewParams);

    mInputEditText = new EditText(mParentActivity);
    LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10);

    layout.addView(mInputEditText, editTextParams);

    setContentView(layout, layoutParams);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    mInputMode = mMsg.inputMode;/* www  .  j a  va2  s .c o  m*/
    mInputFlag = mMsg.inputFlag;
    mReturnType = mMsg.returnType;
    mMaxLength = mMsg.maxLength;

    mTextViewTitle.setText(mMsg.title);
    mInputEditText.setText(mMsg.content);

    int oldImeOptions = mInputEditText.getImeOptions();
    mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    oldImeOptions = mInputEditText.getImeOptions();

    switch (mInputMode) {
    case kEditBoxInputModeAny:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
        break;
    case kEditBoxInputModeEmailAddr:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
        break;
    case kEditBoxInputModeNumeric:
        mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
        break;
    case kEditBoxInputModePhoneNumber:
        mInputModeContraints = InputType.TYPE_CLASS_PHONE;
        break;
    case kEditBoxInputModeUrl:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
        break;
    case kEditBoxInputModeDecimal:
        mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                | InputType.TYPE_NUMBER_FLAG_SIGNED;
        break;
    case kEditBoxInputModeSingleLine:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT;
        break;
    default:

        break;
    }

    if (mIsMultiline) {
        mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
    }

    mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints);

    switch (mInputFlag) {
    case kEditBoxInputFlagPassword:
        mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
        break;
    case kEditBoxInputFlagSensitive:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        break;
    case kEditBoxInputFlagInitialCapsWord:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS;
        break;
    case kEditBoxInputFlagInitialCapsSentence:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
        break;
    case kEditBoxInputFlagInitialCapsAllCharacters:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
        break;
    default:
        break;
    }
    mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints);

    switch (mReturnType) {
    case kKeyboardReturnTypeDefault:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE);
        break;
    case kKeyboardReturnTypeDone:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE);
        break;
    case kKeyboardReturnTypeSend:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND);
        break;
    case kKeyboardReturnTypeSearch:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH);
        break;
    case kKeyboardReturnTypeGo:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO);
        break;
    default:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE);
        break;
    }

    if (mMaxLength > 0) {
        mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxLength) });
    }

    Handler initHandler = new Handler();
    initHandler.postDelayed(new Runnable() {
        public void run() {
            mInputEditText.requestFocus();
            mInputEditText.setSelection(mInputEditText.length());
            openKeyboard();
        }
    }, 200);

    mInputEditText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            // if user didn't set keyboard type,
            // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP'
            if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null
                    && event.getAction() == KeyEvent.ACTION_DOWN)) {
                //Log.d("EditBox", "actionId: "+actionId +",event: "+event);
                mParentActivity.setEditBoxResult(mInputEditText.getText().toString());
                closeKeyboard();
                dismiss();
                return true;
            }
            return false;
        }
    });
}

From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java

private void showAddrEnterDialog() {
    // Set the current dialog
    currentDialog = ADDRESS_ENTER_DIALOG_ID;

    // Build Address Enter Dialog
    AlertDialog.Builder addrEnterBuilder = new AlertDialog.Builder(this);
    addrEnterBuilder.setTitle("Step 3: Enter Location Name / Address");

    // Initialize EditText for user to type the desired address
    addressET = new EditText(this);
    addressET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    addrEnterBuilder.setView(addressET);

    // Set Listeners
    addrEnterBuilder.setPositiveButton("Search", mAddrEnterOnClickListner);
    // Finish the activity when the user presses cancel
    addrEnterBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            setResult(RESULT_OK);/*w  w  w . j  a v  a 2  s  .  co m*/
            finish();
        }
    });
    addrEnterBuilder.setOnKeyListener(mBackKeyListener);

    // Show Address Enter Dialog
    addrEnterDialog = addrEnterBuilder.create();
    addrEnterDialog.show();
}

From source file:com.doodle.android.chips.ChipsView.java

private void init() {
    mDensity = getResources().getDisplayMetrics().density;

    mChipsContainer = new RelativeLayout(getContext());
    addView(mChipsContainer);/*from w w w.j a va  2s  .  c o  m*/

    // Dummy item to prevent AutoCompleteTextView from receiving focus
    LinearLayout linearLayout = new LinearLayout(getContext());
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(0, 0);
    linearLayout.setLayoutParams(params);
    linearLayout.setFocusable(true);
    linearLayout.setFocusableInTouchMode(true);

    mChipsContainer.addView(linearLayout);

    mEditText = new ChipsEditText(getContext(), this);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.topMargin = (int) (SPACING_TOP * mDensity);
    layoutParams.bottomMargin = (int) (SPACING_BOTTOM * mDensity) + mVerticalSpacing;
    mEditText.setLayoutParams(layoutParams);
    mEditText.setMinHeight((int) (CHIP_HEIGHT * mDensity));
    mEditText.setPadding(0, 0, 0, 0);
    mEditText.setLineSpacing(mVerticalSpacing, (CHIP_HEIGHT * mDensity) / mEditText.getLineHeight());
    mEditText.setBackgroundColor(Color.argb(0, 0, 0, 0));
    mEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_UNSPECIFIED);
    mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
            | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    mEditText.setHint(mChipsHintText);

    mChipsContainer.addView(mEditText);

    mRootChipsLayout = new ChipsVerticalLinearLayout(getContext(), mVerticalSpacing);
    mRootChipsLayout.setOrientation(LinearLayout.VERTICAL);
    mRootChipsLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mRootChipsLayout.setPadding(0, (int) (SPACING_TOP * mDensity), 0, 0);
    mChipsContainer.addView(mRootChipsLayout);

    initListener();

    if (isInEditMode()) {
        // preview chips
        LinearLayout editModeLinLayout = new LinearLayout(getContext());
        editModeLinLayout.setOrientation(LinearLayout.HORIZONTAL);
        mChipsContainer.addView(editModeLinLayout);

        View view = new Chip("Test Chip", null, new Contact(null, null, "Test", "asd@asd.de", null)).getView();
        view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        editModeLinLayout.addView(view);

        View view2 = new Chip("Indelible", null, new Contact(null, null, "Test", "asd@asd.de", null), true)
                .getView();
        view2.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        editModeLinLayout.addView(view2);
    }
}