List of usage examples for android.widget LinearLayout VERTICAL
int VERTICAL
To view the source code for android.widget LinearLayout VERTICAL.
Click Source Link
From source file:com.doodle.android.chips.ChipsView.java
private void init() { mDensity = getResources().getDisplayMetrics().density; mChipsContainer = new RelativeLayout(getContext()); addView(mChipsContainer);// w w w . j a va 2s. c om // 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); } }
From source file:com.googlecode.android_scripting.activity.Main.java
protected void initializeViews() { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER_HORIZONTAL); TextView textview = new TextView(this); textview.setText(" PhpForAndroid " + version); ImageView imageView = new ImageView(this); imageView.setImageDrawable(getResources().getDrawable(R.drawable.pfa)); layout.addView(imageView);/*from w w w . ja v a 2 s . c om*/ mButton = new Button(this); mAboutButton = new Button(this); MarginLayoutParams marginParams = new MarginLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); final float scale = getResources().getDisplayMetrics().density; int marginPixels = (int) (MARGIN_DIP * scale + 0.5f); marginParams.setMargins(marginPixels, marginPixels, marginPixels, marginPixels); mButton.setLayoutParams(marginParams); mAboutButton.setLayoutParams(marginParams); layout.addView(textview); layout.addView(mButton); layout.addView(mAboutButton); mProgressLayout = new LinearLayout(this); mProgressLayout.setOrientation(LinearLayout.HORIZONTAL); mProgressLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mProgressLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); LinearLayout bottom = new LinearLayout(this); bottom.setOrientation(LinearLayout.HORIZONTAL); bottom.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); bottom.setGravity(Gravity.CENTER_VERTICAL); mProgressLayout.addView(bottom); TextView message = new TextView(this); message.setText(" In Progress..."); message.setTextSize(20); message.setTypeface(Typeface.DEFAULT_BOLD); message.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); ProgressBar bar = new ProgressBar(this); bar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); bottom.addView(bar); bottom.addView(message); mProgressLayout.setVisibility(View.INVISIBLE); layout.addView(mProgressLayout); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(false); setContentView(layout); }
From source file:com.microsoft.windowsazure.mobileservices.LoginManager.java
/** * Creates the UI for the interactive authentication process * /*from w w w .j av a 2s. co m*/ * @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 */ private void showLoginUI(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.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } } }); wv.getSettings().setJavaScriptEnabled(true); DisplayMetrics displaymetrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int webViewHeight = displaymetrics.heightPixels; wv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, webViewHeight)); 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:edu.rowan.app.fragments.FoodRatingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout view = new LinearLayout(getActivity()); view.setOrientation(LinearLayout.VERTICAL); // view pager indicator TitlePageIndicator pageIndicator = new TitlePageIndicator(getActivity()); pageIndicator.setBackgroundResource(R.color.rowanBrown); fragmentPager = new ViewPager(getActivity()); fragmentPager.setId(VIEW_PAGER_ID);/*from w w w. j ava2s . c o m*/ fragmentAdapter = new FoodRatingAdapter(getChildFragmentManager()); fragmentPager.setAdapter(fragmentAdapter); //View view = inflater.inflate(R.layout.activity_main, container, false); pageIndicator.setViewPager(fragmentPager); view.addView(pageIndicator); view.addView(fragmentPager); return view; }
From source file:org.mariotaku.twidere.activity.TwitterLoginActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { requestSupportWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE); mResolver = getContentResolver();/*from w w w .ja va 2 s.c om*/ mApplication = TwidereApplication.getInstance(this); setContentView(R.layout.twitter_login); mEditUsername = (EditText) findViewById(R.id.username); mEditPassword = (EditText) findViewById(R.id.password); mSignInButton = (Button) findViewById(R.id.sign_in); mSignUpButton = (Button) findViewById(R.id.sign_up); mSigninSignup = (LinearLayout) findViewById(R.id.sign_in_sign_up); mUsernamePassword = (LinearLayout) findViewById(R.id.username_password); mSetColorButton = (ImageButton) findViewById(R.id.set_color); setSupportProgressBarIndeterminateVisibility(false); final long[] account_ids = getActivatedAccountIds(this); getSupportActionBar().setDisplayHomeAsUpEnabled(account_ids.length > 0); Bundle bundle = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState; if (bundle == null) { bundle = new Bundle(); } mRESTBaseURL = bundle.getString(Accounts.REST_BASE_URL); mOAuthBaseURL = bundle.getString(Accounts.OAUTH_BASE_URL); mSigningRESTBaseURL = bundle.getString(Accounts.SIGNING_REST_BASE_URL); mSigningOAuthBaseURL = bundle.getString(Accounts.SIGNING_OAUTH_BASE_URL); if (isNullOrEmpty(mRESTBaseURL)) { mRESTBaseURL = DEFAULT_REST_BASE_URL; } if (isNullOrEmpty(mOAuthBaseURL)) { mOAuthBaseURL = DEFAULT_OAUTH_BASE_URL; } if (isNullOrEmpty(mSigningRESTBaseURL)) { mSigningRESTBaseURL = DEFAULT_SIGNING_REST_BASE_URL; } if (isNullOrEmpty(mSigningOAuthBaseURL)) { mSigningOAuthBaseURL = DEFAULT_SIGNING_OAUTH_BASE_URL; } mUsername = bundle.getString(Accounts.SCREEN_NAME); mPassword = bundle.getString(Accounts.PASSWORD); mAuthType = bundle.getInt(Accounts.AUTH_TYPE); if (bundle.containsKey(Accounts.USER_COLOR)) { mUserColor = bundle.getInt(Accounts.USER_COLOR, Color.TRANSPARENT); } mUsernamePassword.setVisibility(mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? View.GONE : View.VISIBLE); mSigninSignup.setOrientation( mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL); mEditUsername.setText(mUsername); mEditUsername.addTextChangedListener(this); mEditPassword.setText(mPassword); mEditPassword.addTextChangedListener(this); setSignInButton(); setUserColorButton(); if (!mPreferences.getBoolean(PREFERENCE_KEY_API_UPGRADE_CONFIRMED, false)) { final FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentByTag(FRAGMENT_TAG_API_UPGRADE_NOTICE) == null || !fm.findFragmentByTag(FRAGMENT_TAG_API_UPGRADE_NOTICE).isAdded()) { new APIUpgradeConfirmDialog().show(getSupportFragmentManager(), "api_upgrade_notice"); } } }
From source file:jfabrix101.lib.fragmentActivity.AbstractFragmentActivityController.java
/** * Crea un layout verticale utilizzando il solo fragment di destra (il dettaglio) *//*from www . j a v a2 s . c o m*/ @SuppressWarnings("all") protected View makeRightPortraitLayout(LayoutInflater inflater) { if (getLayoutResourceId() > 0) { View v = LayoutInflater.from(this).inflate(getLayoutResourceId(), null); View leftFragment = v.findViewById(getLeftFragmentId()); if (leftFragment != null) { leftFragment.setVisibility(View.GONE); } mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_RIGHT; // getActionBar().setDisplayHomeAsUpEnabled(true); return v; } else { LinearLayout layout = new LinearLayout(this); layout.setPadding(10, 10, 10, 10); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); layout.setOrientation(LinearLayout.VERTICAL); FrameLayout rightFrame = new FrameLayout(this); rightFrame.setId(getRightFragmentId()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); rightFrame.setLayoutParams(lp); layout.addView(rightFrame); mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_RIGHT; // getActionBar().setDisplayHomeAsUpEnabled(true); return layout; } }
From source file:cn.bingoogolapple.androidcommon.adapter.BGADivider.java
@Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (parent.getLayoutManager() == null || parent.getAdapter() == null) { return;/*from www. j av a 2 s . c o m*/ } int itemCount = parent.getAdapter().getItemCount(); BGAHeaderAndFooterAdapter headerAndFooterAdapter = getHeaderAndFooterAdapter(parent); // header footer ? item int realItemCount = itemCount; if (headerAndFooterAdapter != null) { // ?? item realItemCount = headerAndFooterAdapter.getRealItemCount(); } if (mOrientation == LinearLayout.VERTICAL) { drawVertical(canvas, parent, headerAndFooterAdapter, itemCount, realItemCount); } else { drawHorizontal(canvas, parent); } }
From source file:com.sonnychen.aviationhk.views.HomeFragment.java
private void bindVHSKReadings(DataType dataType) { Log.v("HomeFragment", "bindVHSKReadings: " + dataType.toString()); switch (dataType) { case FORECASTS: StringBuilder sb = new StringBuilder(); for (HKOData.Visibility visibility : BaseApplication.Data.VisibilityReadings) sb.append(String.format(Locale.ENGLISH, "%s: %.0f km\n", visibility.Location, visibility.Visibility_10min_KM)); mVisibilityLocal.setText(sb.toString()); if (BaseApplication.RssData.WeatherForecasts != null) { cardList = new ArrayList<>(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd/MM", Locale.ENGLISH); for (HKORss.WeatherForecast forecast : BaseApplication.RssData.WeatherForecasts) { cardList.add(new GenericCardItem(forecast.Date != null ? forecast.Date.toString() : "", forecast.WeatherCartoonURL, String.format(Locale.ENGLISH, "%s<br />%s<br /><br />%s<br />%s", forecast.Date != null ? dateFormat.format(forecast.Date) : "", forecast.Weather, forecast.TemperatureRange, forecast.Wind))); }//from w ww . ja va 2s. co m GridLayoutManager mLayoutManager = new GridLayoutManager(getContext(), getMaxNumberOfFittedColumns(getActivity(), 100), LinearLayoutManager.VERTICAL, false); mExtendedForecasts.setLayoutManager(mLayoutManager); mLayoutManager.setAutoMeasureEnabled(true); mExtendedForecasts.setHasFixedSize(false); mExtendedForecasts.setNestedScrollingEnabled(false); mExtendedForecasts .setAdapter(new GenericRecyclerViewAdapter(getContext(), cardList, LinearLayout.VERTICAL)); } break; case VHSK: mVHSKTemperature.setText(String.format(Locale.ENGLISH, "%.1fC (%.1fC ~ %.1fC)", BaseApplication.Data.VHSK_Temperature_Celsius, BaseApplication.Data.VHSK_TemperatureMin_Celsius, BaseApplication.Data.VHSK_TemperatureMax_Celsius)); mVHSKWind.setText(String.format(Locale.ENGLISH, "%s %s - %s %s %s", BaseApplication.Data.VHSK_WindDirection, Math.round(BaseApplication.Data.VHSK_Wind_Knots) > 0 ? String.format( Locale.ENGLISH, "%d kts", Math.round(BaseApplication.Data.VHSK_Wind_Knots)) : "", getString(R.string.crosswind), Math.round(BaseApplication.Data.VHSK_CrossWind_Knots) > 0 ? String.format(Locale.ENGLISH, "%d kts", Math.round(BaseApplication.Data.VHSK_CrossWind_Knots)) : "nil", Math.round(BaseApplication.Data.VHSK_CrossWind_Knots) > 0 ? (BaseApplication.Data.VHSK_CrossWind_Angle < 0 ? "from the left of 11" : "from the right of 11") : "")); // check for weather minimas mVHSKWind.setTextColor((Math.round(BaseApplication.Data.VHSK_Wind_Knots) > 20 || Math.round(BaseApplication.Data.VHSK_CrossWind_Knots) > 15) ? Color.RED : Color.BLACK); mVHSKPressure .setText(String.format(Locale.ENGLISH, "%.0f hPa", BaseApplication.Data.VHSK_Pressure_hPa)); break; } }
From source file:com.cloudexplorers.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * /*from ww w. j ava2 s . co m*/ * @param url * The url to load. * @param jsonObject */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button ImageButton back = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); try { back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button ImageButton forward = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); try { forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... // Makes the text // NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button ImageButton close = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); try { close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView webview = new WebView(cordova.getActivity()); webview.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(6); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setPluginsEnabled(true); webview.requestFocus(); webview.requestFocusFromTouch(); // Add the back and forward buttons to our action button container // layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = cordova.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }