Search in sources :

Example 21 with EditText

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

the class CreateDirectoryFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();
    final ContentResolver resolver = context.getContentResolver();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
    final EditText editText = (EditText) view.findViewById(android.R.id.text1);
    builder.setTitle(R.string.menu_create_dir);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            createDirectory(editText.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    final AlertDialog dialog = builder.create();
    // Workaround for the problem - virtual keyboard doesn't show on the phone.
    Shared.ensureKeyboardPresent(context, dialog);
    editText.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
                createDirectory(editText.getText().toString());
                dialog.dismiss();
                return true;
            }
            return false;
        }
    });
    return dialog;
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) TextView(android.widget.TextView) ContentResolver(android.content.ContentResolver) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView)

Example 22 with EditText

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

the class ViewPropertyAlphaActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_properties);
    getWindow().getDecorView().postDelayed(new Runnable() {

        @Override
        public void run() {
            startAnim(R.id.button);
            startAnim(R.id.textview);
            startAnim(R.id.spantext);
            startAnim(R.id.edittext);
            startAnim(R.id.selectedtext);
            startAnim(R.id.textviewbackground);
            startAnim(R.id.layout);
            startAnim(R.id.imageview);
            startAnim(myViewAlphaDefault);
            startAnim(myViewAlphaHandled);
            EditText selectedText = (EditText) findViewById(R.id.selectedtext);
            selectedText.setSelection(3, 8);
        }
    }, 2000);
    Button invalidator = (Button) findViewById(R.id.invalidateButton);
    invalidator.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            findViewById(R.id.textview).invalidate();
            findViewById(R.id.spantext).invalidate();
        }
    });
    TextView textView = (TextView) findViewById(R.id.spantext);
    if (textView != null) {
        SpannableStringBuilder text = new SpannableStringBuilder("Now this is a short text message with spans");
        text.setSpan(new BackgroundColorSpan(Color.RED), 0, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        text.setSpan(new ForegroundColorSpan(Color.BLUE), 4, 9, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        text.setSpan(new SuggestionSpan(this, new String[] { "longer" }, 3), 11, 16, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        text.setSpan(new UnderlineSpan(), 17, 20, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        text.setSpan(new ImageSpan(this, R.drawable.icon), 21, 22, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(text);
    }
    LinearLayout container = (LinearLayout) findViewById(R.id.container);
    myViewAlphaDefault = new MyView(this, false);
    myViewAlphaDefault.setLayoutParams(new LinearLayout.LayoutParams(75, 75));
    container.addView(myViewAlphaDefault);
    myViewAlphaHandled = new MyView(this, true);
    myViewAlphaHandled.setLayoutParams(new LinearLayout.LayoutParams(75, 75));
    container.addView(myViewAlphaHandled);
}
Also used : EditText(android.widget.EditText) ForegroundColorSpan(android.text.style.ForegroundColorSpan) TextView(android.widget.TextView) View(android.view.View) UnderlineSpan(android.text.style.UnderlineSpan) Button(android.widget.Button) TextView(android.widget.TextView) SuggestionSpan(android.text.style.SuggestionSpan) SpannableStringBuilder(android.text.SpannableStringBuilder) BackgroundColorSpan(android.text.style.BackgroundColorSpan) LinearLayout(android.widget.LinearLayout) ImageSpan(android.text.style.ImageSpan)

Example 23 with EditText

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

the class DialogActivity method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mLayout = new LinearLayout(this);
    mLayout.setOrientation(LinearLayout.VERTICAL);
    mLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mButton1 = new Button(this);
    //(R.string.open_dialog_scrollable);
    mButton1.setText("Dialog WITHOUT EditText");
    mButton1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            showDialog(DIALOG_WITHOUT_EDITTEXT);
        }
    });
    mButton2 = new Button(this);
    //(R.string.open_dialog_nonscrollable);
    mButton2.setText("Dialog WITH EditText");
    mButton2.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            showDialog(DIALOG_WITH_EDITTEXT);
        }
    });
    mEditText = new EditText(this);
    mLayout.addView(mEditText);
    mLayout.addView(mButton1);
    mLayout.addView(mButton2);
    setContentView(mLayout);
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) ViewGroup(android.view.ViewGroup) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 24 with EditText

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

the class ManyEditTextActivityScrollPanScan method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mRootView = new ScrollView(this);
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < NUM_EDIT_TEXTS; i++) {
        final EditText editText = new EditText(this);
        editText.setText(String.valueOf(i));
        editText.setId(i);
        layout.addView(editText);
    }
    ((ScrollView) mRootView).addView(layout);
    setContentView(mRootView);
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
Also used : EditText(android.widget.EditText) ScrollView(android.widget.ScrollView) LinearLayout(android.widget.LinearLayout)

Example 25 with EditText

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

the class SimplePathsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout layout = new FrameLayout(this);
    EditText text = new EditText(this);
    layout.addView(text, new FrameLayout.LayoutParams(600, 350, Gravity.CENTER));
    text.setText("This is an example of an EditText widget \n" + "using simple paths to create the selection.");
    //text.setSelection(0, text.getText().length());
    setContentView(layout);
}
Also used : EditText(android.widget.EditText) FrameLayout(android.widget.FrameLayout)

Aggregations

EditText (android.widget.EditText)655 View (android.view.View)309 TextView (android.widget.TextView)220 DialogInterface (android.content.DialogInterface)143 AlertDialog (android.app.AlertDialog)126 Button (android.widget.Button)126 Intent (android.content.Intent)99 LinearLayout (android.widget.LinearLayout)79 ImageView (android.widget.ImageView)61 AlertDialog (android.support.v7.app.AlertDialog)54 ScrollView (android.widget.ScrollView)52 LayoutInflater (android.view.LayoutInflater)48 AdapterView (android.widget.AdapterView)46 ViewGroup (android.view.ViewGroup)42 Editable (android.text.Editable)41 Context (android.content.Context)40 RecyclerView (android.support.v7.widget.RecyclerView)40 ListView (android.widget.ListView)39 Dialog (android.app.Dialog)36 Bundle (android.os.Bundle)36