Example usage for android.widget TextView setOnClickListener

List of usage examples for android.widget TextView setOnClickListener

Introduction

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

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.limewoodmedia.nsdroid.fragments.OfficersFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.officers, null, false);
    list = (ListView) root.findViewById(R.id.officers_list);

    officers = new ArrayList<Officer>();
    officersComparator = new OfficersComparator();
    listAdapter = new ArrayAdapter<Officer>(context, 0, officers) {
        @Override//from  ww  w  .  j  ava2 s .  com
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            TextView name, office, authority;
            Officer officer;

            if (convertView == null) {
                view = inflater.inflate(R.layout.officer, null);
            } else {
                view = convertView;
            }
            name = (TextView) view.findViewById(R.id.officer_name);
            name.setMovementMethod(LinkMovementMethod.getInstance());
            office = (TextView) view.findViewById(R.id.officer_office);
            authority = (TextView) view.findViewById(R.id.officer_authority);
            officer = getItem(position);

            // Name
            String oName = TagParser.idToName(officer.nation);
            name.setText(Html.fromHtml(oName));
            // Office
            office.setText(officer.office);
            // Authority
            StringBuilder sb = new StringBuilder();
            int i = 0;
            for (Officer.Authority auth : officer.authority) {
                sb.append(auth.name);
                if (i + 1 < officer.authority.size()) {
                    sb.append(", ");
                }
                i++;
            }
            authority.setText(sb.toString());

            view.setTag(officer);
            view.setOnClickListener(OfficersFragment.this);
            name.setOnClickListener(OfficersFragment.this);
            office.setOnClickListener(OfficersFragment.this);

            return view;
        }
    };
    list.setAdapter(listAdapter);

    return root;
}

From source file:edu.berkeley.boinc.attach.SelectionListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View v = convertView;//  w ww  . ja va 2 s. c  o  m

    LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final ProjectListEntry listItem = entries.get(position);

    v = vi.inflate(R.layout.attach_project_list_layout_listitem, null);
    TextView name = (TextView) v.findViewById(R.id.name);
    TextView description = (TextView) v.findViewById(R.id.description);
    TextView summary = (TextView) v.findViewById(R.id.summary);
    CheckBox cb = (CheckBox) v.findViewById(R.id.cb);
    LinearLayout textWrapper = (LinearLayout) v.findViewById(R.id.text_wrapper);

    if (listItem.am) {
        // element is account manager
        name.setText(activity.getString(R.string.attachproject_acctmgr_header));
        description.setText(activity.getString(R.string.attachproject_acctmgr_list_desc));
        cb.setVisibility(View.GONE);
        summary.setVisibility(View.GONE);
        ImageView button = (ImageView) v.findViewById(R.id.am_button_image);
        button.setVisibility(View.VISIBLE);
        OnClickListener listener = new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Logging.DEBUG)
                    Log.d(Logging.TAG, "SelectionListAdapter: account manager clicked.");
                AcctMgrFragment dialog = new AcctMgrFragment();
                dialog.setReturnToMainActivity(); // configure, so dialog returns to main activity when finished
                dialog.show(activity.getSupportFragmentManager(),
                        activity.getString(R.string.attachproject_acctmgr_header));
            }
        };
        v.setOnClickListener(listener);
        name.setOnClickListener(listener);
        description.setOnClickListener(listener);
        button.setOnClickListener(listener);
    } else {
        // element is project option
        name.setText(listItem.info.name);
        description.setText(listItem.info.generalArea);
        summary.setText(listItem.info.summary);
        cb.setChecked(listItem.checked);
        cb.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                listItem.checked = !listItem.checked;
            }
        });
        textWrapper.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Logging.DEBUG)
                    Log.d(Logging.TAG,
                            "SelectionListAdapter: onProjectClick open info for: " + listItem.info.name);

                ProjectInfoFragment dialog = ProjectInfoFragment.newInstance(listItem.info);
                dialog.show(activity.getSupportFragmentManager(), "ProjectInfoFragment");
            }
        });

    }
    return v;
}

From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java

private void buildLinksSection(Cursor cursor) {
    // Compile list of links (I/O live link, submit feedback, and normal links)
    ViewGroup linkContainer = (ViewGroup) findViewById(R.id.links_container);
    linkContainer.removeAllViews();/*  ww w.  ja  va2s. c om*/

    // Build links section
    // the Object can be either a string URL or an Intent
    List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>();

    long currentTimeMillis = UIUtils.getCurrentTime(this);
    if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) {
        links.add(new Pair<Integer, Object>(R.string.session_link_livestream, getWatchLiveIntent(this)));
    }

    // Add session feedback link, if appropriate
    if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) {
        links.add(new Pair<Integer, Object>(R.string.session_feedback_submitlink, getFeedbackIntent()));
    }

    for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) {
        final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]);
        if (TextUtils.isEmpty(linkUrl)) {
            continue;
        }

        links.add(new Pair<Integer, Object>(SessionsQuery.LINKS_TITLES[i],
                new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl))
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)));
    }

    // Render links
    if (links.size() > 0) {
        LayoutInflater inflater = LayoutInflater.from(this);
        int columns = getResources().getInteger(R.integer.links_columns);

        LinearLayout currentLinkRowView = null;
        for (int i = 0; i < links.size(); i++) {
            final Pair<Integer, Object> link = links.get(i);

            // Create link view
            TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer,
                    false);
            if (link.first == R.string.session_feedback_submitlink) {
                mSubmitFeedbackView = linkView;
            }
            linkView.setText(getString(link.first));
            linkView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    fireLinkEvent(link.first);
                    Intent intent = null;
                    if (link.second instanceof Intent) {
                        intent = (Intent) link.second;
                    } else if (link.second instanceof String) {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second))
                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    }
                    try {
                        startActivity(intent);
                    } catch (ActivityNotFoundException ignored) {
                    }
                }
            });

            // Place it inside a container
            if (columns == 1) {
                linkContainer.addView(linkView);
            } else {
                // create a new link row
                if (i % columns == 0) {
                    currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row,
                            linkContainer, false);
                    currentLinkRowView.setWeightSum(columns);
                    linkContainer.addView(currentLinkRowView);
                }

                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0;
                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1;
                currentLinkRowView.addView(linkView);
            }
        }

        findViewById(R.id.session_links_header).setVisibility(View.VISIBLE);
        findViewById(R.id.links_container).setVisibility(View.VISIBLE);

    } else {
        findViewById(R.id.session_links_header).setVisibility(View.GONE);
        findViewById(R.id.links_container).setVisibility(View.GONE);
    }

}

From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java

private void buildLinksSection(Cursor cursor) {
    final Context context = mRootView.getContext();

    // Compile list of links (I/O live link, submit feedback, and normal links)
    ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container);
    linkContainer.removeAllViews();/*ww  w.j a v a 2  s . com*/

    // Build links section
    // the Object can be either a string URL or an Intent
    List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>();

    long currentTimeMillis = UIUtils.getCurrentTime(context);
    if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) {
        links.add(new Pair<Integer, Object>(R.string.session_link_livestream, getWatchLiveIntent(context)));
    }

    // Add session feedback link, if appropriate
    if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) {
        links.add(new Pair<Integer, Object>(R.string.session_feedback_submitlink, getFeedbackIntent()));
    }

    for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) {
        final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]);
        if (TextUtils.isEmpty(linkUrl)) {
            continue;
        }

        links.add(new Pair<Integer, Object>(SessionsQuery.LINKS_TITLES[i],
                new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl))
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)));
    }

    // Render links
    if (links.size() > 0) {
        LayoutInflater inflater = LayoutInflater.from(context);
        int columns = context.getResources().getInteger(R.integer.links_columns);

        LinearLayout currentLinkRowView = null;
        for (int i = 0; i < links.size(); i++) {
            final Pair<Integer, Object> link = links.get(i);

            // Create link view
            TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer,
                    false);
            if (link.first == R.string.session_feedback_submitlink) {
                mSubmitFeedbackView = linkView;
            }
            linkView.setText(getString(link.first));
            linkView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    fireLinkEvent(link.first);
                    Intent intent = null;
                    if (link.second instanceof Intent) {
                        intent = (Intent) link.second;
                    } else if (link.second instanceof String) {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second))
                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    }
                    try {
                        startActivity(intent);
                    } catch (ActivityNotFoundException ignored) {
                    }
                }
            });

            // Place it inside a container
            if (columns == 1) {
                linkContainer.addView(linkView);
            } else {
                // create a new link row
                if (i % columns == 0) {
                    currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row,
                            linkContainer, false);
                    currentLinkRowView.setWeightSum(columns);
                    linkContainer.addView(currentLinkRowView);
                }

                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0;
                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1;
                currentLinkRowView.addView(linkView);
            }
        }

        mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE);
        mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE);

    } else {
        mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE);
        mRootView.findViewById(R.id.links_container).setVisibility(View.GONE);
    }

}

From source file:com.google.android.apps.flexbox.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initializeStringResources();/*from  w ww.  j a v a 2 s .c om*/

    mFlexboxLayout = (FlexboxLayout) findViewById(R.id.flexbox_layout);
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    if (drawer != null) {
        drawer.addDrawerListener(toggle);
    }
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        navigationView.setNavigationItemSelectedListener(this);
        Menu navigationMenu = navigationView.getMenu();
        initializeFlexDirectionSpinner(navigationMenu);
        initializeFlexWrapSpinner(navigationMenu);
        initializeJustifyContentSpinner(navigationMenu);
        initializeAlignItemsSpinner(navigationMenu);
        initializeAlignContentSpinner(navigationMenu);
    }

    if (savedInstanceState != null) {
        ArrayList<FlexItem> flexItems = savedInstanceState.getParcelableArrayList(FLEX_ITEMS_KEY);
        assert flexItems != null;
        mFlexboxLayout.removeAllViews();
        for (int i = 0; i < flexItems.size(); i++) {
            FlexItem flexItem = flexItems.get(i);
            FlexboxLayout.LayoutParams lp = flexItem.toLayoutParams(this);
            TextView textView = createBaseFlexItemTextView(i);
            ViewCompat.setPaddingRelative(textView, flexItem.paddingStart, flexItem.paddingTop,
                    flexItem.paddingEnd, flexItem.paddingBottom);
            textView.setLayoutParams(lp);
            mFlexboxLayout.addView(textView);
        }
    }

    for (int i = 0; i < mFlexboxLayout.getChildCount(); i++) {
        mFlexboxLayout.getChildAt(i).setOnClickListener(new FlexItemClickListener(i));
    }

    FloatingActionButton addFab = (FloatingActionButton) findViewById(R.id.add_fab);
    if (addFab != null) {
        addFab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int viewIndex = mFlexboxLayout.getChildCount();
                // index starts from 0. New View's index is N if N views ([0, 1, 2, ... N-1])
                // exist.
                TextView textView = createBaseFlexItemTextView(viewIndex);
                textView.setLayoutParams(createDefaultLayoutParams());
                textView.setOnClickListener(new FlexItemClickListener(viewIndex));
                mFlexboxLayout.addView(textView);
            }
        });
    }
    FloatingActionButton removeFab = (FloatingActionButton) findViewById(R.id.remove_fab);
    if (removeFab != null) {
        removeFab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mFlexboxLayout.getChildCount() == 0) {
                    return;
                }
                mFlexboxLayout.removeViewAt(mFlexboxLayout.getChildCount() - 1);
            }
        });
    }
}

From source file:com.oasis.sdk.activity.GooglePlayBillingActivity.java

/**
 * ??????//from   w  w  w  .  j  a v a  2s  . c  o m
 * @param purchase
 */
void alert(final Purchase purchase) {
    final AlertDialog d = new AlertDialog.Builder(this).create();
    d.show();
    d.setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_common_dialog_notitle"));
    d.setCanceledOnTouchOutside(false);
    d.setCancelable(false);
    TextView retry = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_sure"));
    retry.setText(getResources()
            .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_retry")));
    retry.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // ?
            d.dismiss();
            setWaitScreen(true);
            check(purchase);
        }
    });
    TextView close = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_cancle"));
    close.setText(getResources()
            .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_close")));
    close.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            d.dismiss();
            setResultInfo(OASISPlatformConstant.RESULT_EXCEPTION_GOOGLEPAY_EXCEPTION,
                    "?????");
            close();
        }
    });

    TextView content = (TextView) d
            .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_content"));
    content.setText(getResources()
            .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_content")));

}

From source file:com.saarang.samples.apps.iosched.ui.SessionDetailActivity.java

private void buildLinksSection(Cursor cursor) {
    // Compile list of links (I/O live link, submit feedback, and normal links)
    ViewGroup linkContainer = (ViewGroup) findViewById(com.saarang.samples.apps.iosched.R.id.links_container);
    linkContainer.removeAllViews();// ww w  . j  a  v  a 2s.  com

    // Build links section
    // the Object can be either a string URL or an Intent
    List<Pair<Integer, Object>> links = new ArrayList<Pair<Integer, Object>>();

    long currentTimeMillis = UIUtils.getCurrentTime(this);
    if (mHasLivestream && currentTimeMillis > mSessionStart && currentTimeMillis <= mSessionEnd) {
        links.add(new Pair<Integer, Object>(com.saarang.samples.apps.iosched.R.string.session_link_livestream,
                getWatchLiveIntent(this)));
    }

    // Add session feedback link, if appropriate
    if (!mAlreadyGaveFeedback && currentTimeMillis > mSessionEnd - Config.FEEDBACK_MILLIS_BEFORE_SESSION_END) {
        links.add(new Pair<Integer, Object>(
                com.saarang.samples.apps.iosched.R.string.session_feedback_submitlink, getFeedbackIntent()));
    }

    for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) {
        final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]);
        if (TextUtils.isEmpty(linkUrl)) {
            continue;
        }

        links.add(new Pair<Integer, Object>(SessionsQuery.LINKS_TITLES[i],
                new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl))
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)));
    }

    // Render links
    if (links.size() > 0) {
        LayoutInflater inflater = LayoutInflater.from(this);
        int columns = getResources().getInteger(com.saarang.samples.apps.iosched.R.integer.links_columns);

        LinearLayout currentLinkRowView = null;
        for (int i = 0; i < links.size(); i++) {
            final Pair<Integer, Object> link = links.get(i);

            // Create link view
            TextView linkView = (TextView) inflater.inflate(
                    com.saarang.samples.apps.iosched.R.layout.list_item_session_link, linkContainer, false);
            if (link.first == com.saarang.samples.apps.iosched.R.string.session_feedback_submitlink) {
                mSubmitFeedbackView = linkView;
            }
            linkView.setText(getString(link.first));
            linkView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    fireLinkEvent(link.first);
                    Intent intent = null;
                    if (link.second instanceof Intent) {
                        intent = (Intent) link.second;
                    } else if (link.second instanceof String) {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) link.second))
                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    }
                    try {
                        startActivity(intent);
                    } catch (ActivityNotFoundException ignored) {
                    }
                }
            });

            // Place it inside a container
            if (columns == 1) {
                linkContainer.addView(linkView);
            } else {
                // create a new link row
                if (i % columns == 0) {
                    currentLinkRowView = (LinearLayout) inflater.inflate(
                            com.saarang.samples.apps.iosched.R.layout.include_link_row, linkContainer, false);
                    currentLinkRowView.setWeightSum(columns);
                    linkContainer.addView(currentLinkRowView);
                }

                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0;
                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1;
                currentLinkRowView.addView(linkView);
            }
        }

        findViewById(com.saarang.samples.apps.iosched.R.id.session_links_header).setVisibility(View.VISIBLE);
        findViewById(com.saarang.samples.apps.iosched.R.id.links_container).setVisibility(View.VISIBLE);

    } else {
        findViewById(com.saarang.samples.apps.iosched.R.id.session_links_header).setVisibility(View.GONE);
        findViewById(com.saarang.samples.apps.iosched.R.id.links_container).setVisibility(View.GONE);
    }

}

From source file:com.gh4a.IssueLabelListActivity.java

private void fillData() {
    final Typeface condensed = getApplicationContext().condensed;
    LinearLayout ll = (LinearLayout) findViewById(R.id.main_content);
    ll.removeAllViews();/*from  w  ww .ja v a  2 s  .c  o  m*/

    mAllLabelLayout = new ArrayList<Map<String, Object>>();
    for (final Label label : mLabels) {
        Map<String, Object> selectedLabelItems = new HashMap<String, Object>();
        selectedLabelItems.put("label", label);

        final View rowView = getLayoutInflater().inflate(R.layout.row_issue_label, null);
        final View viewColor = (View) rowView.findViewById(R.id.view_color);

        final LinearLayout llEdit = (LinearLayout) rowView.findViewById(R.id.ll_edit);
        selectedLabelItems.put("llEdit", llEdit);

        final EditText etLabel = (EditText) rowView.findViewById(R.id.et_label);
        selectedLabelItems.put("etLabel", etLabel);

        final TextView tvLabel = (TextView) rowView.findViewById(R.id.tv_title);
        selectedLabelItems.put("tvLabel", tvLabel);

        tvLabel.setTypeface(condensed);
        tvLabel.setText(label.getName());

        viewColor.setBackgroundColor(Color.parseColor("#" + label.getColor()));
        selectedLabelItems.put("viewColor", viewColor);
        mAllLabelLayout.add(selectedLabelItems);

        viewColor.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (llEdit.getVisibility() == View.VISIBLE) {
                    llEdit.setVisibility(View.GONE);
                    unselectLabel(tvLabel, viewColor, label.getColor());
                } else {
                    llEdit.setVisibility(View.VISIBLE);
                    selectLabel(tvLabel, viewColor, label.getColor(), true, etLabel);
                    etLabel.setText(label.getName());
                    mActionMode = startActionMode(new EditActionMode(label.getName(), etLabel));
                }
            }
        });

        tvLabel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                LinearLayout llEdit = (LinearLayout) rowView.findViewById(R.id.ll_edit);
                if (llEdit.getVisibility() == View.VISIBLE) {
                    llEdit.setVisibility(View.GONE);
                    unselectLabel(tvLabel, viewColor, label.getColor());
                } else {
                    llEdit.setVisibility(View.VISIBLE);
                    selectLabel(tvLabel, viewColor, label.getColor(), true, etLabel);
                    etLabel.setText(label.getName());
                    mActionMode = startActionMode(new EditActionMode(label.getName(), etLabel));
                }
            }
        });

        if (!StringUtils.isBlank(mSelectedLabel) && mSelectedLabel.equals(label.getName())) {
            selectLabel(tvLabel, viewColor, label.getColor(), false, etLabel);
            llEdit.setVisibility(View.VISIBLE);
            etLabel.setText(label.getName());
        }

        final View color1 = (View) rowView.findViewById(R.id.color_444444);
        color1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color1.getTag(), false, etLabel);
            }
        });

        final View color2 = (View) rowView.findViewById(R.id.color_02d7e1);
        color2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color2.getTag(), false, etLabel);
            }
        });

        final View color3 = (View) rowView.findViewById(R.id.color_02e10c);
        color3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color3.getTag(), false, etLabel);
            }
        });

        final View color4 = (View) rowView.findViewById(R.id.color_0b02e1);
        color4.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color4.getTag(), false, etLabel);
            }
        });

        final View color5 = (View) rowView.findViewById(R.id.color_d7e102);
        color5.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color5.getTag(), false, etLabel);
            }
        });

        final View color6 = (View) rowView.findViewById(R.id.color_DDDDDD);
        color6.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color6.getTag(), false, etLabel);
            }
        });

        final View color7 = (View) rowView.findViewById(R.id.color_e102d8);
        color7.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color7.getTag(), false, etLabel);
            }
        });

        final View color8 = (View) rowView.findViewById(R.id.color_e10c02);
        color8.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                selectLabel(tvLabel, viewColor, (String) color8.getTag(), false, etLabel);
            }
        });

        ll.addView(rowView);
    }
}

From source file:com.xiaoyu.DoctorHelp.chat.chatuidemo.adapter.MessageAdapter.java

/**
 * ???//w  w  w .  j av a 2 s.com
 *
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position,
        View convertView) {
    TextView locationView = ((TextView) convertView.findViewById(R.id.tv_location));
    LocationMessageBody locBody = (LocationMessageBody) message.getBody();
    locationView.setText(locBody.getAddress());
    LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude());
    locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress()));
    locationView.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class))
                    .putExtra("position", position).putExtra("type", EMMessage.Type.LOCATION.ordinal()),
                    ChatActivity.REQUEST_CODE_CONTEXT_MENU);
            return false;
        }
    });

    if (message.direct == EMMessage.Direct.RECEIVE) {
        return;
    }
    // deal with send message
    switch (message.status) {
    case SUCCESS:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    case FAIL:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.VISIBLE);
        break;
    case INPROGRESS:
        holder.pb.setVisibility(View.VISIBLE);
        break;
    default:
        sendMsgInBackground(message, holder);
    }
}

From source file:com.ringdroid.RingdroidEditActivity.java

/**
 * Called from both onCreate and onConfigurationChanged (if the user
 * switched layouts)/*from w w  w  .j  ava2 s .  c om*/
 */
private void loadGui() {
    // Inflate our UI from its XML layout description.
    setContentView(R.layout.editor);
    Utils.addAds(this);
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    mDensity = metrics.density;

    mStartText = (TextView) findViewById(R.id.starttext);
    mStartText.addTextChangedListener(mTextWatcher);
    mEndText = (TextView) findViewById(R.id.endtext);
    mEndText.addTextChangedListener(mTextWatcher);

    mPlayButton = (ImageButton) findViewById(R.id.play);
    mPlayButton.setOnClickListener(mPlayListener);
    mRewindButton = (ImageButton) findViewById(R.id.rew);
    mRewindButton.setOnClickListener(mRewindListener);
    mFfwdButton = (ImageButton) findViewById(R.id.ffwd);
    mFfwdButton.setOnClickListener(mFfwdListener);
    mZoomInButton = (ImageButton) findViewById(R.id.zoom_in);
    mZoomInButton.setOnClickListener(mZoomInListener);
    mZoomOutButton = (ImageButton) findViewById(R.id.zoom_out);
    mZoomOutButton.setOnClickListener(mZoomOutListener);
    mSaveButton = (ImageButton) findViewById(R.id.save);
    mSaveButton.setOnClickListener(mSaveListener);

    TextView markStartButton = (TextView) findViewById(R.id.mark_start);
    markStartButton.setOnClickListener(mMarkStartListener);
    TextView markEndButton = (TextView) findViewById(R.id.mark_end);
    markEndButton.setOnClickListener(mMarkStartListener);

    enableDisableButtons();

    mWaveformView = (WaveformView) findViewById(R.id.waveform);
    mWaveformView.setListener(this);

    mInfo = (TextView) findViewById(R.id.info);
    mInfo.setText(mCaption);

    mMaxPos = 0;
    mLastDisplayedStartPos = -1;
    mLastDisplayedEndPos = -1;

    if (mSoundFile != null) {
        mWaveformView.setSoundFile(mSoundFile);
        mWaveformView.recomputeHeights(mDensity);
        mMaxPos = mWaveformView.maxPos();
    }

    mStartMarker = (MarkerView) findViewById(R.id.startmarker);
    mStartMarker.setListener(this);
    mStartMarker.setAlpha(255);
    mStartMarker.setFocusable(true);
    mStartMarker.setFocusableInTouchMode(true);

    mEndMarker = (MarkerView) findViewById(R.id.endmarker);
    mEndMarker.setListener(this);
    mEndMarker.setAlpha(255);
    mEndMarker.setFocusable(true);
    mEndMarker.setFocusableInTouchMode(true);

    updateDisplay();
}