Example usage for android.widget TextView TextView

List of usage examples for android.widget TextView TextView

Introduction

In this page you can find the example usage for android.widget TextView TextView.

Prototype

public TextView(Context context) 

Source Link

Usage

From source file:android.support.v7.widget.Toolbar.java

/**
 * Set the subtitle of this toolbar./*from   w w  w.jav a 2s  .co  m*/
 *
 * <p>Subtitles should express extended information about the current content.</p>
 *
 * @param subtitle Subtitle to set
 */
public void setSubtitle(CharSequence subtitle) {
    if (!TextUtils.isEmpty(subtitle)) {
        if (mSubtitleTextView == null) {
            final Context context = getContext();
            mSubtitleTextView = new TextView(context);
            mSubtitleTextView.setSingleLine();
            mSubtitleTextView.setEllipsize(TextUtils.TruncateAt.END);
            if (mSubtitleTextAppearance != 0) {
                mSubtitleTextView.setTextAppearance(context, mSubtitleTextAppearance);
            }
            if (mSubtitleTextColor != 0) {
                mSubtitleTextView.setTextColor(mSubtitleTextColor);
            }
        }
        if (mSubtitleTextView.getParent() == null) {
            addSystemView(mSubtitleTextView);
            updateChildVisibilityForExpandedActionView(mSubtitleTextView);
        }
    } else if (mSubtitleTextView != null && mSubtitleTextView.getParent() != null) {
        removeView(mSubtitleTextView);
    }
    if (mSubtitleTextView != null) {
        mSubtitleTextView.setText(subtitle);
    }
    mSubtitleText = subtitle;
}

From source file:cn.com.incito.driver.fragments.infocenter.MyInfoFragment.java

/**
 * ?/*from   w  ww .  java 2s. c  o m*/
 * 
 * @param
 */
private void initAgentInfo(List<Agent> mAgentList) {
    // ?
    if (mAgentList.size() > 0) {
        for (int i = 0; i < mAgentList.size(); i++) {
            // Agent agent = mAgentList.get(i);
            // TextView newAgent = new TextView(getActivity());
            // newAgent.setId(i);
            // LinearLayout.LayoutParams layoutParams = new
            // LinearLayout.LayoutParams(
            // LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            // newAgent.setLayoutParams(layoutParams);
            // newAgent.setText(i + "." + agent.getCompany());
            // newAgent.setOnClickListener(new OnClickListener() {
            //
            // @Override
            // public void onClick(View arg0) {
            // // TODO Auto-generated method
            // // stub
            //
            // }
            // });
            // mAgentsInfo.addView(newAgent);

            //
            gridAdapter = new GridAdapter(getActivity());
            gridAdapter.setList(mAgentList);
            gridView.setAdapter(gridAdapter);
            gridAdapter.notifyDataSetChanged();
        }
    } else {

        TextView noAgent = new TextView(getActivity());
        noAgent.setText("?");
        mAgentsInfo.addView(noAgent);
    }
}

From source file:com.cssweb.android.base.QuoteGridActivity.java

private void AddViewItem(String paramString, int paramInt1, LinearLayout paramLinearLayout, int paramInt2,
        int paramInt3, int paramInt4, boolean paramBoolean) {
    TextView localTextView = new TextView(this);
    float f = this.mFontSize;

    localTextView.setTextSize(f);/*from w w w  . j a v a 2  s  .co m*/
    //??4?
    if (paramInt2 == paramInt4 && paramInt3 == 0 && nameOrcode) {

        if (this.mPaint.measureText(paramString) > textWeight)
            localTextView.setTextSize(13);
    }

    if (n2 == paramInt2) {
        String str = (n1 == 0) ? paramString + low : (n1 == 1) ? paramString + top : paramString;
        localTextView.setText(str);
    } else {
        localTextView.setText(paramString);
    }
    localTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    localTextView.setFocusable(paramBoolean);
    localTextView.setOnClickListener(mClickListener);
    localTextView.setOnLongClickListener(mLongClickListener);
    localTextView.setOnTouchListener(this); //touch
    localTextView.setTag(paramInt2);
    localTextView.setEnabled(paramBoolean);
    localTextView.setSingleLine(false);
    if (paramInt4 == 0 && paramInt3 >= 0) {//
        localTextView.setGravity(Gravity.CENTER);
        int i1 = this.residTitleCol;
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = getResources().getDrawable(i1);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[2]);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 13) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 8) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 10;
        } else if (paramInt3 % 2 == 0) {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[1]);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this));
        //int i9 = (int) Math.max(i8, mPaint.measureText(paramString));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    if (paramInt4 != 0 && paramInt3 >= 0) {
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = getResources().getDrawable(this.residCol);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = getResources().getDrawable(this.residScrollCol[2]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 13) {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
            //localTextView.setWidth(i8+20);
        } else if (paramInt3 == 8) {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 10;
            //localTextView.setWidth(i8+20);
        } else if (paramInt3 % 2 == 0) {
            localDrawable = getResources().getDrawable(this.residScrollCol[1]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = getResources().getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + rowHeight);
        //int i9 = (int) Math.max(i8, mPaint.measureText(paramString));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    //      if ((paramInt3 == j) && (paramInt4 == l)) {
    //         int i13 = this.residTitleScrollCol[l];
    //         localDrawable = localResources.getDrawable(i13);
    //         localTextView.setTextColor(paramInt1);
    //         localTextView.setBackgroundDrawable(localDrawable);
    //         paramLinearLayout.addView(localTextView);
    //         return;
    //      }
}

From source file:com.appdupe.flamer.LoginUsingFacebook.java

private void getTemplateFromResource() {

    // logDebug("getTemplateFromResource   ");
    imgs = res.obtainTypedArray(R.array.galleryimage);

    for (int i = 0; i < imgs.length(); i++) {
        GellaryData gellaryData = new GellaryData();
        gellaryData.setResourceId(imgs.getResourceId(i, -1));
        imagelist.add(gellaryData);/*from  w ww .  j  a va 2  s.c om*/
    }
    page_text = new TextView[imgs.length()];
    count = imagelist.size();
    // logDebug("getTemplateFromResource   count");
    for (int i = 0; i < imagelist.size(); i++) {
        page_text[i] = new TextView(this);

        page_text[i].setTypeface(null, Typeface.BOLD);
        page_text[i].setText(".");
        page_text[i].setTextSize(25);
        page_text[i].setTextColor(android.graphics.Color.GRAY);
        count_layout.addView(page_text[i]);
    }

    // icon =
    // BitmapFactory.decodeResource(this.getResources(),imgs.getResourceId(shre.getInt("itemId",
    // -1)-1,-1));
    // Log.d(TAG, "item index is "+shre.getInt("itemId", -1));
    mAdapterForGalery.notifyDataSetChanged();

}

From source file:android.support.v7ox.widget.Toolbar.java

/**
 * Set the subtitle of this toolbar.//from www  .  j a  v a2s.co m
 *
 * <p>Subtitles should express extended information about the current content.</p>
 *
 * @param subtitle Subtitle to set
 */
public void setSubtitle(CharSequence subtitle) {
    if (!TextUtils.isEmpty(subtitle)) {
        if (mSubtitleTextView == null) {
            final Context context = getContext();
            mSubtitleTextView = new TextView(context);
            mSubtitleTextView.setSingleLine();
            mSubtitleTextView.setEllipsize(TextUtils.TruncateAt.END);
            if (mSubtitleTextAppearance != 0) {
                mSubtitleTextView.setTextAppearance(context, mSubtitleTextAppearance);
            }
            if (mSubtitleTextColor != 0) {
                mSubtitleTextView.setTextColor(mSubtitleTextColor);
            }
        }
        if (!isChildOrHidden(mSubtitleTextView)) {
            addSystemView(mSubtitleTextView, true);
        }
    } else if (mSubtitleTextView != null && isChildOrHidden(mSubtitleTextView)) {
        removeView(mSubtitleTextView);
        mHiddenViews.remove(mSubtitleTextView);
    }
    if (mSubtitleTextView != null) {
        mSubtitleTextView.setText(subtitle);
    }
    mSubtitleText = subtitle;
}

From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    TextView txt = (TextView) convertView;
    if (txt == null) {
        txt = new TextView(getApplication());
        txt.setPadding(UI._8dp, UI._4dp, UI._8dp, UI._4dp);
        txt.setTypeface(UI.defaultTypeface);
        txt.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp);
        txt.setTextColor(defaultTextColors);
    }// w  w w  .jav a 2  s .  c  o m
    txt.setText(getGenreString(position));
    return txt;
}

From source file:com.b44t.ui.ActionBar.BottomSheet.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Window window = getWindow();/*  ww  w.  ja  va2s. c  o  m*/
    window.setWindowAnimations(R.style.DialogNoAnimation);
    setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (containerView == null) {
        containerView = new FrameLayout(getContext()) {
            @Override
            public boolean hasOverlappingRendering() {
                return false;
            }
        };
        containerView.setBackgroundDrawable(shadowDrawable);
        containerView.setPadding(backgroundPaddingLeft,
                (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft,
                (applyBottomPadding ? AndroidUtilities.dp(8) : 0));
    }
    if (Build.VERSION.SDK_INT >= 21) {
        containerView.setFitsSystemWindows(true);
    }
    containerView.setVisibility(View.INVISIBLE);
    container.addView(containerView, 0,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM));

    if (customView != null) {
        if (customView.getParent() != null) {
            ViewGroup viewGroup = (ViewGroup) customView.getParent();
            viewGroup.removeView(customView);
        }
        containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
    } else {
        int topOffset = 0;
        if (title != null) {
            TextView titleView = new TextView(getContext());
            titleView.setLines(1);
            titleView.setSingleLine(true);
            titleView.setText(title);
            titleView.setTextColor(0xff757575);
            titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
            titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
            titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8));
            titleView.setGravity(Gravity.CENTER_VERTICAL);
            containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48));
            titleView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });
            topOffset += 48;
        }
        if (items != null) {
            FrameLayout rowLayout = null;
            int lastRowLayoutNum = 0;
            for (int a = 0; a < items.length; a++) {
                BottomSheetCell cell = new BottomSheetCell(getContext(), 0);
                cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0);
                containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48,
                        Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0));
                topOffset += 48;
                cell.setTag(a);
                cell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dismissWithButtonClick((Integer) v.getTag());
                    }
                });
                itemViews.add(cell);
            }
        }
    }

    WindowManager.LayoutParams params = window.getAttributes();
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.dimAmount = 0;
    params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    if (!focusable) {
        params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    }
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;
    window.setAttributes(params);
}

From source file:com.example.drugsformarinemammals.Dose_Information.java

public TextView createTitleTextView() {
    TextView title_textview = new TextView(this);
    title_textview.setTextSize(20);//from  ww  w  .j  a  va 2s  . co m
    title_textview.setTextColor(getResources().getColor(R.color.darkGray));
    title_textview.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
    return title_textview;
}

From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java

private void createTableLayoutTrainAvailability() {

    if (mPage.contains("SORRY")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Not a valid class, Please select a different class and try again.");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();// www . ja  v a2  s . co m
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("ISL Of")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("ERROR")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("Network Connectivity")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("unavailable")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText(
                "Response from server:\n\nYour request could not be processed now.\nPlease try again later!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) {
        Iterator iterator = null;
        try {
            iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator();
        } catch (Exception e) {
            Log.i("TrainDetails", mPage);
            e.printStackTrace();
            return;
        }
        mListAv = new ArrayList<List<String>>();
        List<String> list;
        Element tmp;
        tmp = (Element) iterator.next();
        list = new ArrayList<String>();
        list.add(tmp.select("th").get(0).text());
        list.add("Date");
        list.add(tmp.select("th").get(2).text());
        //list.add(tmp.select("th").get(3).text());
        mListAv.add(list);
        while (iterator.hasNext()) {
            tmp = (Element) iterator.next();
            if (!tmp.hasText()) {
                continue;
            }
            list = new ArrayList<String>();
            list.add(tmp.select("td").get(0).text());
            list.add(tmp.select("td").get(1).text());
            list.add(tmp.select("td").get(2).text());
            //list.add(tmp.select("td").get(3).text());
            mListAv.add(list);
        }
        mDetails = new Details(mListAv, TrainEnquiry.AVAILABILITY, mTrainNumber);
    } else {
        mListAv = mDetails.getList();
    }
    mTblLayoutAv = new TableLayout(mActivity);
    TableRow row;
    TextView tv1, tv2, tv3;
    mTblLayoutAv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    for (int i = 0; i < mListAv.size(); i++) {
        row = new TableRow(mActivity);
        tv1 = new TextView(mActivity);
        tv2 = new TextView(mActivity);
        tv3 = new TextView(mActivity);
        //tv4 = new TextView(mActivity);

        tv1.setText("   " + mListAv.get(i).get(0));
        tv2.setText("   " + mListAv.get(i).get(1));
        tv3.setText("   " + mListAv.get(i).get(2));
        //tv4.setText("   " + mListAv.get(i).get(3));

        tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        tv3.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        //tv4.setTextAppearance(mActivity,android.R.style.TextAppearance_DeviceDefault_Medium);

        tv1.setPadding(5, 5, 5, 5);
        tv2.setPadding(5, 5, 5, 5);
        tv3.setPadding(5, 5, 5, 5);
        //tv4.setPadding(5,5,5,5);

        /*tv2.setBackgroundResource(R.drawable.card_divider);
        tv3.setBackgroundResource(R.drawable.card_divider);
        tv4.setBackgroundResource(R.drawable.card_divider);*/

        row.addView(tv1);
        row.addView(tv2);
        row.addView(tv3);
        //row.addView(tv4);

        row.setBackgroundResource(R.drawable.button_selector);
        row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
        row.setOnClickListener(this);
        mTblLayoutAv.addView(row);
    }
    LinearLayout ll = new LinearLayout(mActivity);
    ScrollView scrollView = new ScrollView(mActivity);
    TextView textViewTrnDtls = new TextView(mActivity);
    textViewTrnDtls.setText("Availability details:");
    textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
    textViewTrnDtls.setPadding(10, 10, 10, 10);
    ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.addView(textViewTrnDtls);
    ll.addView(mTblLayoutAv);
    scrollView.addView(ll);
    mFrameLayout.removeAllViews();
    mFrameLayout.addView(scrollView);
    if (mDialog.isShowing()) {
        mDialog.cancel();
    }
}

From source file:com.phonegap.bossbolo.plugin.inappbrowser.InAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param jsonObject/*ww w  .j av  a2  s  .c  o m*/
 * @param header
 */
public String showWebPage(final String url, HashMap<String, Boolean> features, final String header) {
    // Determine if we should hide the location bar.
    showLocationBar = true;
    showZoomControls = true;
    openWindowHidden = false;
    if (features != null) {
        Boolean show = features.get(LOCATION);
        if (show != null) {
            showLocationBar = show.booleanValue();
        }
        Boolean zoom = features.get(ZOOM);
        if (zoom != null) {
            showZoomControls = zoom.booleanValue();
        }
        Boolean hidden = features.get(HIDDEN);
        if (hidden != null) {
            openWindowHidden = hidden.booleanValue();
        }
        Boolean hardwareBack = features.get(HARDWARE_BACK_BUTTON);
        if (hardwareBack != null) {
            hadwareBackButton = hardwareBack.booleanValue();
        }
        Boolean cache = features.get(CLEAR_ALL_CACHE);
        if (cache != null) {
            clearAllCache = cache.booleanValue();
        } else {
            cache = features.get(CLEAR_SESSION_CACHE);
            if (cache != null) {
                clearSessionCache = cache.booleanValue();
            }
        }
    }

    final CordovaWebView thatWebView = this.webView;

    // 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;
        }

        @SuppressLint("NewApi")
        public void run() {
            int backgroundColor = Color.parseColor("#46bff7");
            // Let's create the main dialog
            dialog = new InAppBrowserDialog(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.setInAppBroswer(getInAppBrowser());

            // Main container layout
            LinearLayout main = new LinearLayout(cordova.getActivity());
            main.setOrientation(LinearLayout.VERTICAL);

            // Toolbar layout  header
            RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
            //Please, no more black! 
            toolbar.setBackgroundColor(android.graphics.Color.LTGRAY);
            toolbar.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(50)));
            toolbar.setPadding(this.dpToPixels(8), this.dpToPixels(10), this.dpToPixels(8),
                    this.dpToPixels(10));
            toolbar.setHorizontalGravity(Gravity.LEFT);
            toolbar.setVerticalGravity(Gravity.TOP);
            toolbar.setBackgroundColor(backgroundColor);

            // 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
            Button back = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
            back.setLayoutParams(backLayoutParams);
            back.setContentDescription("Back Button");
            back.setId(2);
            back.setWidth(this.dpToPixels(34));
            back.setHeight(this.dpToPixels(31));
            Resources activityRes = cordova.getActivity().getResources();
            int backResId = activityRes.getIdentifier("back", "drawable",
                    cordova.getActivity().getPackageName());
            Drawable backIcon = activityRes.getDrawable(backResId);
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                back.setBackgroundDrawable(backIcon);
            } else {
                back.setBackground(backIcon);
            }
            back.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    closeDialog();
                    //                        goBack();
                }
            });

            // Edit Text Box
            titletext = new TextView(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            textLayoutParams.addRule(RelativeLayout.RIGHT_OF, this.dpToPixels(65));
            textLayoutParams.addRule(RelativeLayout.LEFT_OF, this.dpToPixels(10));
            titletext.setLayoutParams(textLayoutParams);
            titletext.setId(3);
            titletext.setSingleLine(true);
            titletext.setText(header);
            titletext.setTextColor(Color.WHITE);
            titletext.setGravity(Gravity.CENTER);
            titletext.setTextSize(TypedValue.COMPLEX_UNIT_PX, this.dpToPixels(20));
            titletext.setSingleLine();
            titletext.setEllipsize(TruncateAt.END);

            edittext = new EditText(cordova.getActivity());
            RelativeLayout.LayoutParams editLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            editLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
            editLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
            edittext.setLayoutParams(textLayoutParams);
            edittext.setId(4);
            edittext.setSingleLine(true);
            edittext.setText(url);
            edittext.setVisibility(View.GONE);

            // Forward button
            /*Button forward = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
            forward.setLayoutParams(forwardLayoutParams);
            forward.setContentDescription("Forward Button");
            forward.setId(3);
            int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
            Drawable fwdIcon = activityRes.getDrawable(fwdResId);
            if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
            {
            forward.setBackgroundDrawable(fwdIcon);
            }
            else
            {
            forward.setBackground(fwdIcon);
            }
            forward.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                goForward();
            }
            });
                    
            // Edit Text Box
            edittext = new TextView(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_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/Done button
            Button close = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            close.setLayoutParams(closeLayoutParams);
            forward.setContentDescription("Close Button");
            close.setId(5);
            int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
            Drawable closeIcon = activityRes.getDrawable(closeResId);
            if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
            {
            close.setBackgroundDrawable(closeIcon);
            }
            else
            {
            close.setBackground(closeIcon);
            }
            close.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                closeDialog();
            }
            });*/

            // WebView
            inAppWebView = new WebView(cordova.getActivity());
            inAppWebView.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView));
            WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
            inAppWebView.setWebViewClient(client);
            WebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setBuiltInZoomControls(getShowZoomControls());
            settings.setPluginState(android.webkit.WebSettings.PluginState.ON);

            //Toggle whether this is enabled or not!
            Bundle appSettings = cordova.getActivity().getIntent().getExtras();
            boolean enableDatabase = appSettings == null ? true
                    : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
            if (enableDatabase) {
                String databasePath = cordova.getActivity().getApplicationContext()
                        .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath();
                settings.setDatabasePath(databasePath);
                settings.setDatabaseEnabled(true);
            }
            settings.setDomStorageEnabled(true);

            if (clearAllCache) {
                CookieManager.getInstance().removeAllCookie();
            } else if (clearSessionCache) {
                CookieManager.getInstance().removeSessionCookie();
            }

            inAppWebView.loadUrl(url);
            inAppWebView.setId(6);
            inAppWebView.getSettings().setLoadWithOverviewMode(true);
            inAppWebView.getSettings().setUseWideViewPort(true);
            inAppWebView.requestFocus();
            inAppWebView.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(titletext);
            //                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(inAppWebView);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
            // the goal of openhidden is to load the url and not display it
            // Show() needs to be called to cause the URL to be loaded
            if (openWindowHidden) {
                dialog.hide();
            }
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
    return "";
}