List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
From source file:mobisocial.musubi.objects.FileObj.java
@Override public View createView(Context context, ViewGroup frame) { LinearLayout container = new LinearLayout(context); container.setLayoutParams(CommonLayouts.FULL_WIDTH); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); TextView valueTV = new TextView(context); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT); valueTV.setPadding(4, 0, 0, 0);//from ww w . ja v a 2 s . c o m container.addView(imageView); container.addView(valueTV); return container; }
From source file:com.nextgis.mobile.map.LocalTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, int type, final Uri uri, final LocalTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);/*from w w w . j a va 2s. c om*/ final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(), android.R.layout.simple_spinner_item); final Spinner spinner = new Spinner(map.getContext()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); adapter.add(map.getContext().getString(R.string.tmstype_qtiles)); adapter.add(map.getContext().getString(R.string.tmstype_osm)); adapter.add(map.getContext().getString(R.string.tmstype_normal)); adapter.add(map.getContext().getString(R.string.tmstype_ngw)); if (type == TMSTYPE_OSM) { spinner.setSelection(1); } else { spinner.setSelection(2); } final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerType); linearLayout.addView(spinner); new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int tmsType = 0; switch (spinner.getSelectedItemPosition()) { case 0: case 1: tmsType = TMSTYPE_OSM; break; case 2: case 3: tmsType = TMSTYPE_NORMAL; break; } if (bCreate) { create(map, input.getText().toString(), tmsType, uri); } else { layer.setName(input.getText().toString()); layer.setTMSType(tmsType); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }
From source file:com.cairoconfessions.MainActivity.java
public void report(View view) { final EditText edit = new EditText(this); final RadioGroup choices = new RadioGroup(this); edit.setText("I would like to report this confession"); final String[] selectedItem = getResources().getStringArray(R.array.report_choices); for (int i = 0; i < selectedItem.length; i++) { RadioButton choice = new RadioButton(this); choice.setText(selectedItem[i]); choices.addView(choice);/*from w w w. j a v a 2 s.c o m*/ } choices.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { // checkedId is the RadioButton selected edit.setText("I would like to report this confession as " + ((RadioButton) group.findViewById(checkedId)).getText().toString()); } }); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(choices); ll.addView(edit); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Choose which categories:").setView(ll) .setPositiveButton(R.string.send, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked OK button reportReceived(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked Cancel button } }).show(); }
From source file:com.example.hllut.app.Deprecated.MainActivity.java
/** * fill the "liters of petrol" textView, as well as drawing the petrol barrels *///from w w w. j a v a2 s . co m private void drawPetrol() { //TODO use the bundle float litersOfPetrol = (TOTAL_CO2 / CO2_PER_LITRE_PETROL); TextView tv = (TextView) findViewById(R.id.litersTextView); tv.setText("Burning " + String.format("%.2f", litersOfPetrol) + " liters of petrol"); TableLayout layout = (TableLayout) findViewById(R.id.petrolContainer); TableRow newRow = new TableRow(this); LinearLayout linLay = new LinearLayout(this); linLay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); newRow.setLayoutParams( new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); newRow.setPadding(10, 10, 10, 10); for (int i = 1; i < (int) litersOfPetrol + 1; i++) { // // TODO: To many images fuck up formatting // Create images ImageView im = new ImageView(this); im.setImageResource(R.drawable.oil_barrel); im.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); //barrells per row = 7 if (i % 7 == 0) { // if you have gone 7 laps // print what you have linLay.addView(im); newRow.addView(linLay, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); layout.addView(newRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); newRow = new TableRow(this); linLay = new LinearLayout(this); linLay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); newRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); newRow.setPadding(10, 10, 10, 10); } else { linLay.addView(im); } } newRow.addView(linLay, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); layout.addView(newRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); }
From source file:com.fivetrue.workout.timer.view.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/*from w ww. j a v a 2 s .co m*/ setWillNotDraw(false); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); dividerMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerMargin, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); tabIconPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabIconPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabTextSize, dm); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_indicatorColor, indicatorColor); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_indicatorHeight, indicatorHeight); dividerMargin = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_dividerMargin, dividerMargin); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_tabPadding, tabPadding); tabIconPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_tabIconPadding, tabIconPadding); tabBackgroundColor = a.getColor(R.styleable.PagerSlidingTabStrip_tabBackgroundColor, tabBackgroundColor); tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_tabTextSize, tabTextSize); tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_tabTextColor, tabTextColor); selectTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_selectedTabTextColor, selectTextColor); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_tabTextAllCaps, textAllCaps); textOutline = a.getBoolean(R.styleable.PagerSlidingTabStrip_tabTextOutline, textOutline); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_scrollOffset, scrollOffset); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_shouldExpand, shouldExpand); a.recycle(); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); addView(tabsContainer); mPaintIndicator = new Paint(); mPaintIndicator.setAntiAlias(true); mPaintIndicator.setColor(indicatorColor); mPaintIndicator.setStyle(Paint.Style.FILL); mPaintBackround = new Paint(); mPaintBackround.setAntiAlias(true); mPaintBackround.setColor(tabBackgroundColor); mPaintBackround.setStyle(Paint.Style.FILL); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.mediaexplorer.remote.MexRemoteActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from ww w .j a va 2 s.c o m*/ this.setTitle(R.string.app_name); dbg = "MexWebremote"; text_view = (TextView) findViewById(R.id.text); web_view = (WebView) findViewById(R.id.link_view); web_view.getSettings().setJavaScriptEnabled(true);/* /* Future: setOverScrollMode is API level >8 * web_view.setOverScrollMode (OVER_SCROLL_NEVER); */ web_view.setBackgroundColor(0); web_view.setWebViewClient(new WebViewClient() { /* for some reason we only get critical errors so an auth error * is not handled here which is why there is some crack that test * the connection with a special httpclient */ @Override public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler, final String host, final String realm) { String[] userpass = new String[2]; userpass = view.getHttpAuthUsernamePassword(host, realm); HttpResponse response = null; HttpGet httpget; DefaultHttpClient httpclient; String target_host; int target_port; target_host = MexRemoteActivity.this.target_host; target_port = MexRemoteActivity.this.target_port; /* We may get null from getHttpAuthUsernamePassword which will * break the setCredentials so junk used instead to keep * it happy. */ Log.d(dbg, "using the set httpauth, testing auth using client"); try { if (userpass == null) { userpass = new String[2]; userpass[0] = "none"; userpass[1] = "none"; } } catch (Exception e) { userpass = new String[2]; userpass[0] = "none"; userpass[1] = "none"; } /* Log.d ("debug", * "trying: GET http://"+userpass[0]+":"+userpass[1]+"@"+target_host+":"+target_port+"/"); */ /* We're going to test the authentication credentials that we * have before using them so that we can act on the response. */ httpclient = new DefaultHttpClient(); httpget = new HttpGet("http://" + target_host + ":" + target_port + "/"); httpclient.getCredentialsProvider().setCredentials(new AuthScope(target_host, target_port), new UsernamePasswordCredentials(userpass[0], userpass[1])); try { response = httpclient.execute(httpget); } catch (IOException e) { Log.d(dbg, "Problem executing the http get"); e.printStackTrace(); } Log.d(dbg, "HTTP reponse:" + Integer.toString(response.getStatusLine().getStatusCode())); if (response.getStatusLine().getStatusCode() == 401) { /* We got Authentication failed (401) so ask user for u/p */ /* login dialog box */ final AlertDialog.Builder logindialog; final EditText user; final EditText pass; LinearLayout layout; LayoutParams params; TextView label_username; TextView label_password; logindialog = new AlertDialog.Builder(MexRemoteActivity.this); logindialog.setTitle("Mex Webremote login"); user = new EditText(MexRemoteActivity.this); pass = new EditText(MexRemoteActivity.this); layout = new LinearLayout(MexRemoteActivity.this); pass.setTransformationMethod(new PasswordTransformationMethod()); layout.setOrientation(LinearLayout.VERTICAL); params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layout.setLayoutParams(params); user.setLayoutParams(params); pass.setLayoutParams(params); label_username = new TextView(MexRemoteActivity.this); label_password = new TextView(MexRemoteActivity.this); label_username.setText("Username:"); label_password.setText("Password:"); layout.addView(label_username); layout.addView(user); layout.addView(label_password); layout.addView(pass); logindialog.setView(layout); logindialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); logindialog.setPositiveButton("Login", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String uvalue = user.getText().toString().trim(); String pvalue = pass.getText().toString().trim(); view.setHttpAuthUsernamePassword(host, realm, uvalue, pvalue); handler.proceed(uvalue, pvalue); } }); logindialog.show(); /* End login dialog box */ } else /* We didn't get a 401 */ { handler.proceed(userpass[0], userpass[1]); } } /* End onReceivedHttpAuthRequest */ }); /* End Override */ /* Run mdns to check for service in a "runnable" (async) */ handler.post(new Runnable() { public void run() { startMdns(); } }); dialog = ProgressDialog.show(MexRemoteActivity.this, "", "Searching...", true); /* Let's put something in the webview while we're waiting */ String summary = "<html><head><style>body { background-color: #000000; color: #ffffff; }></style></head><body><p>Searching for the media explorer webservice</p><p>More infomation on <a href=\"http://media-explorer.github.com\" >Media Explorer's home page</a></p></body></html>"; web_view.loadData(summary, "text/html", "utf-8"); }
From source file:jp.mau.twappremover.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { ScrollView contents = new ScrollView(this); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); contents.addView(layout);/* w ww. j a v a 2 s .c o m*/ AssetManager asm = getResources().getAssets(); String[] filelist = null; try { filelist = asm.list("licenses"); } catch (Exception ex) { ex.printStackTrace(); } if (filelist != null) { for (String file : filelist) { Gen.debug(file); InputStream is = null; BufferedReader br = null; String txt = ""; try { is = getAssets().open("licenses/" + file); br = new BufferedReader(new InputStreamReader(is)); String str; while ((str = br.readLine()) != null) { txt += str + "\n"; } } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (is != null) is.close(); } catch (Exception ex) { } try { if (br != null) br.close(); } catch (Exception ex) { } } TextView tv = new TextView(this); tv.setText(txt); layout.addView(tv); } } // final PopupView dialog = new PopupView(this); dialog.setDialog().setLabels(getString(R.string.activity_main_dlgtitle_oss), "") .setView(contents, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) .setCancelable(true) .setPositiveBtn(getString(R.string.activity_main_dlgbtn_oss), new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }).show(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.grarak.kerneladiutor.utils.ViewUtils.java
public static Dialog dialogEditText(String text, final DialogInterface.OnClickListener negativeListener, final OnDialogEditTextListener onDialogEditTextListener, int inputType, Context context) { LinearLayout layout = new LinearLayout(context); int padding = (int) context.getResources().getDimension(R.dimen.dialog_padding); layout.setPadding(padding, padding, padding, padding); final AppCompatEditText editText = new AppCompatEditText(context); editText.setGravity(Gravity.CENTER); editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (text != null) { editText.append(text);/*from www. j av a 2 s . c om*/ } editText.setSingleLine(true); if (inputType >= 0) { editText.setInputType(inputType); } layout.addView(editText); Dialog dialog = new Dialog(context).setView(layout); if (negativeListener != null) { dialog.setNegativeButton(context.getString(R.string.cancel), negativeListener); } if (onDialogEditTextListener != null) { dialog.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onDialogEditTextListener.onClick(editText.getText().toString()); } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (negativeListener != null) { negativeListener.onClick(dialog, 0); } } }); } return dialog; }
From source file:com.azure.webapi.LoginManager.java
/** * Creates the UI for the interactive authentication process * /*from www . j a v a 2s. c om*/ * @param provider * The provider used for the authentication process * @param startUrl * The initial URL for the authentication process * @param endUrl * The final URL for the authentication process * @param context * The context used to create the authentication dialog * @param callback * Callback to invoke when the authentication process finishes */ protected void showLoginUI(MobileServiceAuthenticationProvider provider, final String startUrl, final String endUrl, final Context context, LoginUIOperationCallback callback) { if (startUrl == null || startUrl == "") { throw new IllegalArgumentException("startUrl can not be null or empty"); } if (endUrl == null || endUrl == "") { throw new IllegalArgumentException("endUrl can not be null or empty"); } if (context == null) { throw new IllegalArgumentException("context can not be null"); } final LoginUIOperationCallback externalCallback = callback; final AlertDialog.Builder builder = new AlertDialog.Builder(context); // Create the Web View to show the login page final WebView wv = new WebView(context); builder.setTitle("Connecting to a service"); builder.setCancelable(true); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } } }); // Set cancel button's action builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } wv.destroy(); } }); wv.getSettings().setJavaScriptEnabled(true); wv.requestFocus(View.FOCUS_DOWN); wv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) { if (!view.hasFocus()) { view.requestFocus(); } } return false; } }); // Create a LinearLayout and add the WebView to the Layout LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(wv); // Add a dummy EditText to the layout as a workaround for a bug // that prevents showing the keyboard for the WebView on some devices EditText dummyEditText = new EditText(context); dummyEditText.setVisibility(View.GONE); layout.addView(dummyEditText); // Add the layout to the dialog builder.setView(layout); final AlertDialog dialog = builder.create(); wv.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // If the URL of the started page matches with the final URL // format, the login process finished if (isFinalUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(url, null); } dialog.dismiss(); } super.onPageStarted(view, url, favicon); } // Checks if the given URL matches with the final URL's format private boolean isFinalUrl(String url) { if (url == null) { return false; } return url.startsWith(endUrl); } // Checks if the given URL matches with the start URL's format private boolean isStartUrl(String url) { if (url == null) { return false; } return url.startsWith(startUrl); } @Override public void onPageFinished(WebView view, String url) { if (isStartUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException( "Logging in with the selected authentication provider is not enabled")); } dialog.dismiss(); } } }); wv.loadUrl(startUrl); dialog.show(); }
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;//from w ww . j a v a 2 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; } }); }