Example usage for android.widget LinearLayout setClickable

List of usage examples for android.widget LinearLayout setClickable

Introduction

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

Prototype

public void setClickable(boolean clickable) 

Source Link

Document

Enables or disables click events for this view.

Usage

From source file:org.borderstone.tagtags.TTStartActivity.java

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

    this.setTheme(R.style.AppTheme);
    this.setContentView(R.layout.activity_start);

    Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
    //toolbar.inflateMenu(R.menu.menu_start);
    toolbar.setTitle("TagTags");

    toolbar.setVisibility(View.VISIBLE);

    TTStartActivity.me = getApplicationContext();

    protocol.setAction("android.intent.action.PROTOCOL");
    settings.setAction("android.intent.action.SETTINGS");

    Constants.init(new File(this.getFilesDir(), "bsettings.txt"), this.getApplicationContext());
    Constants.fileListener = this;

    /*Load variables that are stored in a text file
      keeping version info and info about third party
      resources here, for easy editing*/
    try {/*from ww w .  j  av a2  s  .c o m*/
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(this.getResources().openRawResource(R.raw.appinfo)));

        String line = reader.readLine();

        String[] t;
        while (line != null) {
            t = line.split(":");
            if (line.startsWith("#thirdparty:"))
                thirdparty += t[1] + "\n";
            else if (line.startsWith("#recentchanges:"))
                recentchanges += "-- " + t[1] + "\n";

            line = reader.readLine();
        }

        //just to remove the final new line.
        if (!thirdparty.equals(""))
            thirdparty = thirdparty.substring(0, thirdparty.length() - 1);
        if (!recentchanges.equals(""))
            recentchanges = recentchanges.substring(0, recentchanges.length() - 1);
    } catch (Exception ignored) {
    }

    //Most of the code below is purely for aesthetics!

    txtPhilosophy = new BTitleLabel(this);
    txtPhilosophy.setTypeface(Typeface.DEFAULT_BOLD);
    txtPhilosophy.setLayoutParams(Constants.defaultParams);
    txtPhilosophy.setOnClickListener(this);
    txtPhilosophy.setTextColor(Color.BLACK);

    txtVersion = new BStandardLabel(this);
    txtVersion.setText("Recent changes:\n" + recentchanges);
    txtVersion.setLayoutParams(Constants.defaultParams);
    txtVersion.setTextColor(Color.BLACK);

    try {
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        toolbar.setSubtitle("v. " + pInfo.versionName);
    } catch (PackageManager.NameNotFoundException ignored) {
    }

    toolbar.setNavigationIcon(R.drawable.drawer);

    ImageView slu = new ImageView(this);
    ImageView sites = new ImageView(this);

    slu.setImageResource(R.drawable.slulogo);
    sites.setImageResource(R.drawable.sites);

    LinearLayout llLogos = new LinearLayout(this);
    llLogos.setOrientation(LinearLayout.HORIZONTAL);
    llLogos.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);

    llLogos.addView(slu);
    llLogos.addView(sites);

    setPhiloText();

    LinearLayout back = (LinearLayout) this.findViewById(R.id.back);
    back.setOrientation(LinearLayout.VERTICAL);

    txtPhilosophy.setLayoutParams(Constants.defaultParams);
    txtPhilosophy.setBackgroundResource(R.drawable.border);

    txtVersion.setLayoutParams(Constants.defaultParams);
    txtVersion.setBackgroundResource(R.drawable.border_recurring);

    back.addView(txtPhilosophy);
    back.addView(txtVersion);
    back.addView(llLogos);

    lblSettings = new BButton(this);
    lblDownload = new BButton(this);

    lblDownload.setIcon(R.drawable.download);
    lblSettings.setIcon(R.drawable.settings);

    lblSettings.setText("Settings");
    lblDownload.setText("Download from server");

    lblSettings.setOnClickListener(this);
    lblDownload.setOnClickListener(this);

    if (!checkPermissions()) {
        final Intent intro = new Intent();
        intro.setAction("android.intent.action.INTRO");

        this.startActivity(intro);
    }

    BTitleLabel lblProperties = new BTitleLabel(this);
    BTitleLabel lblLocal = new BTitleLabel(this);
    fileNavView = new BFileNavView(this, this);

    lblProperties.setTextSize(Constants.fontSize + 2);
    lblLocal.setTextSize(Constants.fontSize + 2);

    lblProperties.setText("PROPERTIES");
    lblProperties.setTextColor(Color.WHITE);
    lblProperties.setGravity(Gravity.CENTER);
    lblLocal.setText("LOCAL FILES");
    lblLocal.setTextColor(Color.WHITE);
    lblLocal.setGravity(Gravity.CENTER);

    final DrawerLayout drawerLayout = (DrawerLayout) this.findViewById(R.id.startDrawerLayout);
    final LinearLayout drawer = (LinearLayout) this.findViewById(R.id.drawer);
    drawer.setClickable(false);
    drawer.bringToFront();

    drawer.addView(lblProperties);
    drawer.addView(lblDownload);
    drawer.addView(lblSettings);
    drawer.addView(lblLocal);
    drawer.addView(fileNavView);

    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!drawerLayout.isDrawerOpen(Gravity.LEFT))
                drawerLayout.openDrawer(Gravity.LEFT);
            else
                drawerLayout.closeDrawer(Gravity.LEFT);
        }
    });
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

/**
 * Executed when tabhost is created/*from   w  w w  . ja  v a2 s . c  o m*/
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // ----------------- GUI ------------
    resources = SetResources(); // ---Load Prefs and Modify resources
    // accordingly
    setContentView(R.layout.factivity_tabhost); // ---------- Content view
    ctx = this;

    btSetup = new Button(ctx);

    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    btSetup.setLayoutParams(params);

    RelativeLayout rl = (RelativeLayout) findViewById(R.id.tbs);
    rl.addView(btSetup);
    btSetup.bringToFront();

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

            if (Fragment_Issue_Details.mfrag_issue_details != null) {
                FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                ft.remove(Fragment_Issue_Details.mfrag_issue_details);
                ft.commit();
                getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
            }

            mTabHost.getTabWidget().getChildAt(4).findViewWithTag("hbar")
                    .setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_orange));
            startActivity(new Intent(ctx, Activity_Setup.class));
        }
    });

    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);

    mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

    // ---------------------------------------
    for (int i = 0; i < NTabs; i++)
        mTabSpec[i] = mTabHost.newTabSpec("tid" + Integer.toString(i));

    mD_Main = getResources().getDrawable(R.drawable.ic_map);
    mD_List = getResources().getDrawable(R.drawable.ic_list);
    mD_Report = getResources().getDrawable(R.drawable.ic_plus);
    mD_Filters = getResources().getDrawable(R.drawable.ic_filter);
    mD_Setup = getResources().getDrawable(R.drawable.ic_settings);

    // -------------- Set icons and texts localized per tab -------------
    LinearLayout llA = make_Active_Tab(resources.getString(R.string.Map), mD_Main);
    llA.setClickable(true);
    LinearLayout llB = make_Inactive_Tab(resources.getString(R.string.List), mD_List);
    LinearLayout llC = make_Inactive_Tab(resources.getString(R.string.Report), mD_Report);
    LinearLayout llD = make_Inactive_Tab(resources.getString(R.string.Filter), mD_Filters);
    LinearLayout llE = make_Inactive_Tab(resources.getString(R.string.Settings), mD_Setup);

    mTabSpec[0].setIndicator(llA);
    mTabSpec[1].setIndicator(llB);
    mTabSpec[2].setIndicator(llC);
    mTabSpec[3].setIndicator(llD);
    mTabSpec[4].setIndicator(llE);

    // Add tabSpec to the TabHost to display
    mTabHost.addTab(mTabSpec[0], Fragment_Map.class, null);
    mTabHost.addTab(mTabSpec[1], Fragment_List.class, null);
    mTabHost.addTab(mTabSpec[2], Fragment_NewIssueA.class, null);
    mTabHost.addTab(mTabSpec[3], Fragment_Filters.class, null);
    mTabHost.addTab(mTabSpec[4], null, null); // implemented with a button
    // overlapped because there
    // was no fragment for
    // Preferences in support
    // lib v4

    mTabHost.setOnTabChangedListener(this);

    mTabHost.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            btSetup.setWidth(mTabHost.getTabWidget().getChildAt(4).getWidth());
            btSetup.setHeight(mTabHost.getTabWidget().getChildAt(4).getHeight());
            btSetup.bringToFront();
        }
    });

}

From source file:mobisocial.musubi.objects.IntroductionObj.java

@Override
public View createView(Context context, ViewGroup frame) {
    LinearLayout wrap = new LinearLayout(context);
    wrap.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    wrap.setOrientation(LinearLayout.VERTICAL);
    wrap.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    wrap.setEnabled(false);//from w  ww  . ja  v a  2s.  c o m
    wrap.setFocusableInTouchMode(false);
    wrap.setFocusable(false);
    wrap.setClickable(false);

    TextView title = new TextView(context);
    title.setText(R.string.introduced);
    title.setTypeface(null, Typeface.BOLD);
    title.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    wrap.addView(title);

    Gallery intro = new Gallery(context);
    intro.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    hackGalleryInit(context, intro);
    wrap.addView(intro);
    return wrap;
}

From source file:com.gh4a.IssueActivity.java

private void fillData() {
    new LoadCommentsTask(this).execute();

    Typeface boldCondensed = getApplicationContext().boldCondensed;

    ListView lvComments = (ListView) findViewById(R.id.list_view);
    // set details inside listview header
    LayoutInflater infalter = getLayoutInflater();
    LinearLayout mHeader = (LinearLayout) infalter.inflate(R.layout.issue_header, lvComments, false);
    mHeader.setClickable(false);

    lvComments.addHeaderView(mHeader, null, false);

    RelativeLayout rlComment = (RelativeLayout) findViewById(R.id.rl_comment);
    if (!isAuthorized()) {
        rlComment.setVisibility(View.GONE);
    }/*from w  w w .jav  a  2s. c  o m*/

    TextView tvCommentTitle = (TextView) mHeader.findViewById(R.id.comment_title);
    mCommentAdapter = new CommentAdapter(IssueActivity.this, new ArrayList<Comment>(), mIssue.getNumber(),
            mIssue.getState(), mRepoOwner, mRepoName);
    lvComments.setAdapter(mCommentAdapter);

    ImageView ivGravatar = (ImageView) mHeader.findViewById(R.id.iv_gravatar);
    aq.id(R.id.iv_gravatar).image(GravatarUtils.getGravatarUrl(mIssue.getUser().getGravatarId()), true, false,
            0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN);

    ivGravatar.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getUser().getLogin(), null);
        }
    });

    TextView tvExtra = (TextView) mHeader.findViewById(R.id.tv_extra);
    TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state);
    TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title);
    TextView tvDescTitle = (TextView) mHeader.findViewById(R.id.desc_title);
    tvDescTitle.setTypeface(getApplicationContext().boldCondensed);
    tvDescTitle.setTextColor(Color.parseColor("#0099cc"));

    tvCommentTitle.setTypeface(getApplicationContext().boldCondensed);
    tvCommentTitle.setTextColor(Color.parseColor("#0099cc"));
    tvCommentTitle
            .setText(getResources().getString(R.string.issue_comments) + " (" + mIssue.getComments() + ")");

    TextView tvDesc = (TextView) mHeader.findViewById(R.id.tv_desc);
    tvDesc.setMovementMethod(LinkMovementMethod.getInstance());

    TextView tvMilestone = (TextView) mHeader.findViewById(R.id.tv_milestone);

    ImageView ivComment = (ImageView) findViewById(R.id.iv_comment);
    if (Gh4Application.THEME == R.style.DefaultTheme) {
        ivComment.setImageResource(R.drawable.social_send_now_dark);
    }
    ivComment.setBackgroundResource(R.drawable.abs__list_selector_holo_dark);
    ivComment.setPadding(5, 2, 5, 2);
    ivComment.setOnClickListener(this);

    tvExtra.setText(mIssue.getUser().getLogin() + "\n" + pt.format(mIssue.getCreatedAt()));
    tvState.setTextColor(Color.WHITE);
    if ("closed".equals(mIssue.getState())) {
        tvState.setBackgroundResource(R.drawable.default_red_box);
        tvState.setText("C\nL\nO\nS\nE\nD");
    } else {
        tvState.setBackgroundResource(R.drawable.default_green_box);
        tvState.setText("O\nP\nE\nN");
    }
    tvTitle.setText(mIssue.getTitle());
    tvTitle.setTypeface(boldCondensed);

    boolean showInfoBox = false;
    if (mIssue.getAssignee() != null) {
        showInfoBox = true;
        TextView tvAssignee = (TextView) mHeader.findViewById(R.id.tv_assignee);
        tvAssignee.setText(mIssue.getAssignee().getLogin() + " is assigned");
        tvAssignee.setVisibility(View.VISIBLE);
        tvAssignee.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                getApplicationContext().openUserInfoActivity(IssueActivity.this,
                        mIssue.getAssignee().getLogin(), null);
            }
        });

        ImageView ivAssignee = (ImageView) mHeader.findViewById(R.id.iv_assignee);

        aq.id(R.id.iv_assignee).image(GravatarUtils.getGravatarUrl(mIssue.getAssignee().getGravatarId()), true,
                false, 0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN);

        ivAssignee.setVisibility(View.VISIBLE);
        ivAssignee.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                getApplicationContext().openUserInfoActivity(IssueActivity.this,
                        mIssue.getAssignee().getLogin(), null);
            }
        });
    }

    if (mIssue.getMilestone() != null) {
        showInfoBox = true;
        tvMilestone.setText(
                getResources().getString(R.string.issue_milestone) + ": " + mIssue.getMilestone().getTitle());
    } else {
        tvMilestone.setVisibility(View.GONE);
    }

    String body = mIssue.getBodyHtml();
    if (!StringUtils.isBlank(body)) {
        HttpImageGetter imageGetter = new HttpImageGetter(this);
        body = HtmlUtils.format(body).toString();
        imageGetter.bind(tvDesc, body, mIssue.getNumber());
    }

    LinearLayout llLabels = (LinearLayout) findViewById(R.id.ll_labels);
    List<Label> labels = mIssue.getLabels();

    if (labels != null && !labels.isEmpty()) {
        showInfoBox = true;
        for (Label label : labels) {
            TextView tvLabel = new TextView(this);
            tvLabel.setSingleLine(true);
            tvLabel.setText(label.getName());
            tvLabel.setTextAppearance(this, R.style.default_text_small);
            tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor()));
            tvLabel.setPadding(5, 2, 5, 2);
            int r = Color.red(Color.parseColor("#" + label.getColor()));
            int g = Color.green(Color.parseColor("#" + label.getColor()));
            int b = Color.blue(Color.parseColor("#" + label.getColor()));
            if (r + g + b < 383) {
                tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_dark));
            } else {
                tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_light));
            }
            llLabels.addView(tvLabel);

            View v = new View(this);
            v.setLayoutParams(new LayoutParams(5, LayoutParams.WRAP_CONTENT));
            llLabels.addView(v);
        }
    } else {
        llLabels.setVisibility(View.GONE);
    }

    TextView tvPull = (TextView) mHeader.findViewById(R.id.tv_pull);
    if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) {
        showInfoBox = true;
        tvPull.setVisibility(View.VISIBLE);
        tvPull.setOnClickListener(this);
    }

    if (!showInfoBox) {
        RelativeLayout rl = (RelativeLayout) mHeader.findViewById(R.id.info_box);
        rl.setVisibility(View.GONE);
    }
}

From source file:com.example.zf_android.activity.MerchantEdit.java

@Override
protected void onActivityResult(final int requestCode, int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK) {
        return;//w w  w .  j a va 2  s . c  om
    }
    String value = "";
    if (data != null) {
        value = data.getStringExtra("value");
    }
    switch (requestCode) {
    case TYPE_1:
        merchantEntity.setTitle(value);
        tv1.setText(value);
        break;
    case TYPE_2:
        merchantEntity.setLegalPersonName(value);
        tv2.setText(value);
        break;
    case TYPE_3:
        merchantEntity.setLegalPersonCardId(value);
        tv3.setText(value);
        break;
    case TYPE_4:
        merchantEntity.setBusinessLicenseNo(value);
        tv4.setText(value);
        break;
    case TYPE_5:
        merchantEntity.setTaxRegisteredNo(value);
        tv5.setText(value);
        break;
    case TYPE_6:
        merchantEntity.setOrganizationCodeNo(value);
        tv6.setText(value);
        break;
    case TYPE_7:
        Province province = (Province) data.getSerializableExtra(Constants.CityIntent.SELECTED_PROVINCE);
        City city = (City) data.getSerializableExtra(Constants.CityIntent.SELECTED_CITY);
        if (province == null || city == null) {
            merchantEntity.setCityId(0);
            tv7.setText("");
        } else {
            merchantEntity.setCityId(city.getId());
            tv7.setText(province.getName() + city.getName());
        }

        break;
    case TYPE_KHYH:
        merchantEntity.setAccountBankName(value);
        tvkhyh.setText(value);
        break;
    case TYPE_8:
        merchantEntity.setBankOpenAccount(value);
        tv8.setText(value);
        break;

    case REQUEST_UPLOAD_IMAGE:
    case REQUEST_TAKE_PHOTO: {
        final LinearLayout layout = linearLayout.get(MerchantEdit.this.type);
        final Handler handler = new Handler() {
            private int type;

            @Override
            public void handleMessage(Message msg) {
                this.type = MerchantEdit.this.type;
                if (msg.what == 1) {
                    // CommonUtil.toastShort(MerchantEdit.this,
                    // (String) msg.obj);
                    layout.setClickable(false);
                    layout.findViewById(R.id.imgView).setVisibility(View.VISIBLE);
                    layout.findViewById(R.id.textView).setVisibility(View.GONE);
                    String url = (String) msg.obj;
                    layout.setClickable(true);
                    switch (type) {
                    case TYPE_10:
                        merchantEntity.setCardIdFrontPhotoPath(url);
                        break;
                    case TYPE_11:
                        merchantEntity.setCardIdBackPhotoPath(url);
                        break;
                    case TYPE_12:
                        merchantEntity.setBodyPhotoPath(url);
                        break;
                    case TYPE_13:
                        merchantEntity.setLicenseNoPicPath(url);
                        break;
                    case TYPE_14:
                        merchantEntity.setTaxNoPicPath(url);
                        break;
                    case TYPE_15:
                        merchantEntity.setOrgCodeNoPicPath(url);
                        break;
                    case TYPE_16:
                        merchantEntity.setAccountPicPath(url);
                        break;
                    default:
                        break;
                    }
                } else {
                    CommonUtil.toastShort(MerchantEdit.this, getString(R.string.toast_upload_failed));
                    layout.setClickable(true);
                }

            }
        };
        if (null != layout) {
            ImageView imgView = (ImageView) layout.findViewById(R.id.imgView);
            TextView textView = (TextView) layout.findViewById(R.id.textView);
            imgView.setVisibility(View.GONE);
            textView.setVisibility(View.VISIBLE);
            textView.setText(getString(R.string.apply_uploading));
            layout.setClickable(false);
        }
        new Thread() {
            @Override
            public void run() {
                String realPath = "";
                if (requestCode == REQUEST_TAKE_PHOTO) {
                    realPath = photoPath;
                } else {
                    Uri uri = data.getData();
                    if (uri != null) {
                        realPath = Tools.getRealPathFromURI(MerchantEdit.this, uri);
                    }
                }
                if (TextUtils.isEmpty(realPath)) {
                    handler.sendEmptyMessage(0);
                    return;
                }
                CommonUtil.uploadFile(realPath, "img", new CommonUtil.OnUploadListener() {
                    @Override
                    public void onSuccess(String result) {
                        try {
                            JSONObject jo = new JSONObject(result);
                            String url = jo.getString("result");
                            Message msg = new Message();
                            msg.what = 1;
                            msg.obj = url;
                            handler.sendMessage(msg);
                        } catch (JSONException e) {
                            handler.sendEmptyMessage(0);
                        }
                    }

                    @Override
                    public void onFailed(String message) {
                        handler.sendEmptyMessage(0);
                    }
                });
            }
        }.start();
        break;
    }
    default:
        break;
    }
}

From source file:com.push.app.HomeActivity.java

private void initViews() {

    LinearLayout firstItemView = (LinearLayout) getLayoutInflater().inflate(R.layout.first_item_view, null);
    firstItemHeadline = (TextView) firstItemView.findViewById(R.id.firstPostHeadline);
    firstItemDescription = (TextView) firstItemView.findViewById(R.id.postDescription);
    firstItemDateandAuthor = (TextView) firstItemView.findViewById(R.id.first_post_Date);
    firstPostImage = (ImageView) firstItemView.findViewById(R.id.firstPostImage);
    // This is required to disable header's list selector effect
    mListView.addHeaderView(firstItemView);
    firstItemView.setClickable(false);

}

From source file:edu.ptu.navpattern.tooltip.Tooltip.java

private View getContentView(final Builder builder) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(builder.mBackgroundColor);
    drawable.setCornerRadius(builder.mCornerRadius);
    LinearLayout vgContent = new LinearLayout(builder.mContext);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        vgContent.setBackground(drawable);
    } else {//from  w  w  w .ja v a 2 s  .c  om
        //noinspection deprecation
        vgContent.setBackgroundDrawable(drawable);
    }
    int padding = (int) builder.mPadding;
    vgContent.setPadding(padding, padding, padding, padding);
    vgContent.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
    textViewParams.gravity = Gravity.CENTER;
    textViewParams.topMargin = 1;
    vgContent.setLayoutParams(textViewParams);
    vgContent.setDividerDrawable(vgContent.getResources().getDrawable(R.drawable.divider_line));
    vgContent.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);

    if (builder.itemText != null && builder.itemText.length > 0) {
        for (int i = 0; i < builder.itemText.length; i++) {

            TextView textView = new TextView(builder.mContext);
            textView.setText(builder.itemText[i]);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 44);
            textView.setTextColor(0xffffffff);
            textView.setGravity(Gravity.CENTER_VERTICAL);
            if (builder.itemLogo != null && builder.itemLogo.length > i) {
                Drawable drawableLeft = builder.mContext.getResources().getDrawable(builder.itemLogo[i]);
                /// ??,??.
                //                    drawableLeft.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                //                    textView.setCompoundDrawables(drawableLeft, null, null, null);
                //                    textView.setCompoundDrawablePadding(4);
                //                    textView.setBackgroundDrawable(drawableLeft);
                LinearLayout linearLayout = new LinearLayout(builder.mContext);
                linearLayout.setMinimumHeight((int) dpToPx(44f));
                linearLayout.setOrientation(LinearLayout.HORIZONTAL);
                linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                ImageView icon = new ImageView(builder.mContext);
                icon.setImageDrawable(drawableLeft);
                linearLayout.addView(icon);
                linearLayout.addView(textView);
                vgContent.addView(linearLayout);
                final int position = i;
                linearLayout.setClickable(false);
                linearLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (builder.mOnItemClickListener != null) {
                            builder.mOnItemClickListener.onClick(position);
                        }
                        mTouchListener.onTouch(v,
                                MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
                                        MotionEvent.ACTION_UP, v.getLeft() + 5, v.getTop() + 5, 0));
                    }
                });
            } else {
                vgContent.addView(textView);
                final int position = i;
                textView.setClickable(false);
                textView.setMinimumHeight((int) dpToPx(44f));
                textView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (builder.mOnItemClickListener != null) {
                            builder.mOnItemClickListener.onClick(position);
                        }
                        mTouchListener.onTouch(v, null);
                    }
                });
            }
        }

    }

    mArrowView = new ImageView(builder.mContext);
    mArrowView.setImageDrawable(builder.mArrowDrawable);

    LinearLayout.LayoutParams arrowLayoutParams;
    if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) {
        arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowWidth, (int) builder.mArrowHeight,
                0);
    } else {
        arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowHeight, (int) builder.mArrowWidth,
                0);
    }
    arrowLayoutParams.gravity = Gravity.CENTER;
    mArrowView.setLayoutParams(arrowLayoutParams);

    mContentView = new LinearLayout(builder.mContext);
    mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mContentView.setOrientation(mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayout.HORIZONTAL
            : LinearLayout.VERTICAL);

    padding = (int) dpToPx(5);

    switch (mGravity) {
    case Gravity.START:
        mContentView.setPadding(0, 0, padding, 0);
        break;
    case Gravity.TOP:
    case Gravity.BOTTOM:
        mContentView.setPadding(padding, 0, padding, 0);
        break;
    case Gravity.END:
        mContentView.setPadding(padding, 0, 0, 0);
        break;
    }

    if (mGravity == Gravity.TOP || mGravity == Gravity.START) {
        mContentView.addView(vgContent);
        mContentView.addView(mArrowView);
    } else {
        mContentView.addView(mArrowView);
        mContentView.addView(vgContent);
    }

    if (builder.isCancelable || builder.isDismissOnClick) {
        mContentView.setOnTouchListener(mTouchListener);
    }
    return mContentView;
}

From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java

public void setOverlayVisibility(boolean isVisible) {
    final LinearLayout overlay = (LinearLayout) findViewById(R.id.overlay);

    if (isVisible) {
        overlay.setVisibility(View.VISIBLE);
        overlay.setClickable(true);
        overlay.bringToFront();/*from ww w  .j  a v  a 2 s.co m*/
    } else {
        overlay.setVisibility(View.GONE);
    }
}

From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java

private void ensureTitle() {
    if (!TextUtils.isEmpty(titleText) || !TextUtils.isEmpty(messageText)) {
        LinearLayout titleContainer = new LinearLayout(getActivity());
        titleContainer.setOrientation(LinearLayout.VERTICAL);
        titleContainer.setGravity(Gravity.CENTER);
        titleContainer.setBackgroundColor(Color.WHITE);
        titleContainer//from  w  w  w .  j  a  v a  2s .com
                .setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(56)));

        if (!TextUtils.isEmpty(titleText)) {
            TextView title = new TextView(getActivity());
            title.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
            title.setText(titleText);
            title.setGravity(Gravity.CENTER_HORIZONTAL);
            title.setTextColor(COLOR_TITLE);
            title.getPaint().setFakeBoldText(true);
            titleContainer.addView(title);
        }

        if (!TextUtils.isEmpty(messageText)) {
            TextView message = new TextView(getActivity());
            message.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
            message.setGravity(Gravity.CENTER_HORIZONTAL);
            message.setText(messageText);
            message.setTextColor(COLOR_TITLE);
            titleContainer.addView(message);
        }

        titleContainer.setClickable(true);
        titleContainer.setFocusableInTouchMode(true);

        sheetContainer.addView(titleContainer);
        sheetContainer.addView(createLine());
    }
}

From source file:io.github.trulyfree.easyaspi.MainActivity.java

/**
 *
 *///from  w  w w .  ja  va2 s  .  c o  m
private void resetConfigReturned() {
    final ImageView configResponseBlock = (ImageView) findViewById(R.id.block_module_returned);
    LinearLayout layout = (LinearLayout) findViewById(R.id.module_returned_config);
    EditText moduleName = (EditText) findViewById(R.id.module_returned_configname);
    EditText moduleVersion = (EditText) findViewById(R.id.module_returned_configversion);
    EditText moduleConfigUrl = (EditText) findViewById(R.id.module_returned_configurl);
    EditText moduleJarUrl = (EditText) findViewById(R.id.module_returned_jarurl);
    LinearLayout moduleDependencies = (LinearLayout) findViewById(R.id.module_returned_dependencies);
    Button validate = (Button) findViewById(R.id.module_returned_validate);
    Button cancel = (Button) findViewById(R.id.module_returned_cancel);
    moduleName.setText(R.string.module_returned_configname);
    moduleVersion.setText(R.string.module_returned_configversion);
    moduleConfigUrl.setText(R.string.module_returned_configurl);
    moduleJarUrl.setText(R.string.module_returned_jarurl);
    moduleDependencies.removeAllViewsInLayout();
    validate.setOnClickListener(null);
    cancel.setOnClickListener(null);
    final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorClear);
    final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(ANIMATION_DURATION);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            configResponseBlock.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    layout.setClickable(false);
    configResponseBlock.setVisibility(View.VISIBLE);
    colorAnimation.start();
}