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.iaraby.template.view.fragment.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    // UI/*from   ww  w  .  j av  a 2s. c o  m*/
    TextView appTitle = (TextView) rootView.findViewById(R.id.title_view);
    TextView listButton = (TextView) rootView.findViewById(R.id.list_button);
    TextView favButton = (TextView) rootView.findViewById(R.id.fav_button);
    TextView moreButton = (TextView) rootView.findViewById(R.id.more_button);

    // Click
    listButton.setOnClickListener(this);
    favButton.setOnClickListener(this);
    moreButton.setOnClickListener(this);

    // Process
    FontManager.getInstance(getActivity()).setTextFont(appTitle, FontManager.TITLE);
    FontManager.getInstance(getActivity()).setTextFont(listButton, FontManager.TITLE);
    FontManager.getInstance(getActivity()).setTextFont(favButton, FontManager.TITLE);
    FontManager.getInstance(getActivity()).setTextFont(moreButton, FontManager.TITLE);

    return rootView;
}

From source file:com.msopentech.applicationgateway.AgentsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    try {//ww w  . java  2s .  c  om
        super.onCreate(savedInstanceState);
        setContentView(R.layout.agent_list);

        TextView cancelButton = (TextView) findViewById(R.id.agent_cancel_button);
        cancelButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                try {
                    final Intent resultIntent = getIntent();
                    setResult(RESULT_CANCELED, resultIntent);
                    finish();
                } catch (final Exception e) {
                    Utility.showAlertDialog(AgentsActivity.class.getSimpleName()
                            + "cancelButton onClick listener failed. " + e.toString(), AgentsActivity.this);
                }
            }
        });

        final ConnectionTraits traits = (ConnectionTraits) getIntent()
                .getSerializableExtra(EnterpriseBrowserActivity.EXTRAS_TRAITS_KEY);

        Router.performRequest(Router.ACTION_OBTAIN_AGENTS, new Object[] { traits }, AgentsActivity.this,
                AgentsActivity.this);

        mAgentsListView = (ListView) AgentsActivity.this.findViewById(R.id.agent_agents_list);
        mAgentsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
                try {
                    String selectedAgentName = mAgentsListView.getItemAtPosition(position).toString();
                    final Intent resultIntent = getIntent();

                    if (!selectedAgentName.startsWith(IN_USE_MARK)) {
                        ConnectionTraits resultTraits = new ConnectionTraits().setToken(traits.token)
                                .setAgent(mAgentsDataStorage.elementAt(position - 1));

                        Router.performRequest(Router.ACTION_OBTAIN_SESSION, new Object[] { resultTraits },
                                new OnOperationExecutionListener() {
                                    @Override
                                    public void onExecutionComplete(int operation, Object[] result) {
                                        final ConnectionTraits traits = (ConnectionTraits) result[1];
                                        if (traits.isError()) {
                                            AgentsActivity.this.runOnUiThread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    Utility.showToastNotification(traits.error);
                                                    return;
                                                }
                                            });
                                            setResult(RESULT_CANCELED, resultIntent);
                                            finish();
                                        }
                                        AuthPreferences.storePreferredAgent(traits.agent);
                                        resultIntent.putExtra(EnterpriseBrowserActivity.EXTRAS_TRAITS_KEY,
                                                traits);
                                        setResult(RESULT_OK, resultIntent);
                                        finish();
                                    }

                                    @Override
                                    public void onBeforeExecution(int operation) {
                                    }
                                }, AgentsActivity.this);
                    } else {
                        setResult(RESULT_OK, resultIntent);
                        finish();
                    }
                } catch (Exception e) {
                    Utility.showAlertDialog(e.toString(), AgentsActivity.this);
                    return;
                }
            }
        });
    } catch (Exception e) {
        Utility.showAlertDialog(e.toString(), this);
        return;
    }
}

From source file:com.fizz.StickyFragment.java

@Override
public void onStart() {
    super.onStart();
    LinearLayout ll = (LinearLayout) getActivity().findViewById(R.id.ll);
    for (int i = 0; i < drinks.length; i++) {
        TextView tt = new TextView(getActivity());
        tt.setText(drinks[i].toUpperCase(Locale.US) + "\n" + ingredients[i]);
        tt.setPadding(15, 15, 15, 15);//ww  w  .j  a  v  a  2  s .c om
        tt.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drink = ((TextView) v).getText().toString();
                try {
                    Intent venmoIntent = VenmoLibrary.openVenmoPayment("1684", "Fizz", "8123744601", "0.01",
                            drink, "pay");
                    startActivityForResult(venmoIntent, 1);
                    // 1 is the requestCode we are using for Venmo. Feel
                    // free to change this to another number.

                    // Venmo native app not install on device, so let's
                    // instead open a mobile web version of Venmo in a
                    // WebView
                } catch (android.content.ActivityNotFoundException e) {
                    Log.e("Fizz", "onClicked");
                    {
                        Intent venmoIntent = new Intent(getActivity(), VenmoWebViewActivity.class);
                        String venmo_uri = VenmoLibrary.openVenmoPaymentInWebView("1684", "Fizz", "8123744601",
                                "0.01", "Drink", "pay");
                        venmoIntent.putExtra("url", venmo_uri);
                        startActivityForResult(venmoIntent, 1);
                    }
                    //} catch (android.content.ActivityNotFoundException e) {
                    //e.printStackTrace() ;
                }
            }
        });
        tt.setTextSize(22);
        if (textnum % 2 == 0) {
            tt.setBackgroundColor(Color.argb(0, 51, 181, 229));
            tt.setTextColor(Color.argb(255, 51, 181, 229));
        } else {
            tt.setBackgroundColor(Color.argb(240, 51, 181, 229));
            tt.setTextColor(Color.argb(255, 255, 255, 255));
        }
        tt.setTypeface(SplashActivity.tp);
        ll.addView(tt);
        textnum++;
    }
}

From source file:com.jbirdvegas.mgerrit.cards.PatchSetCommentsCard.java

public View setViewValue(Cursor cursor, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.commit_comment, parent, false);
    }//from w ww.  j a  v a  2 s .  c o  m

    ViewHolder viewHolder = (ViewHolder) convertView.getTag();
    if (viewHolder == null) {
        viewHolder = new ViewHolder(convertView);
        convertView.setTag(viewHolder);
    }

    setIndicies(cursor);

    TextView author = viewHolder.authorTextView;
    Integer authorNumber = cursor.getInt(authorId_index);
    author.setTag(authorNumber);
    author.setText(cursor.getString(authorName_index));
    author.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setTrackingUser((Integer) v.getTag());
        }
    });

    String timestamp = cursor.getString(timestamp_index);
    if (timestamp != null) {
        viewHolder.timestamp.setText(Tools.prettyPrintDate(mContext, timestamp,
                Prefs.getServerTimeZone(mContext), Prefs.getLocalTimeZone(mContext)));
    }

    // setup styled comments
    // use Linkify to automatically linking http/email/addresses
    Linkify.addLinks(viewHolder.commentMessage, Linkify.ALL);
    // replace replace emoticons with drawables
    viewHolder.commentMessage
            .setText(EmoticonSupportHelper.getSmiledText(mContext, cursor.getString(message_index)));

    // set gravatar icon for commenter
    viewHolder.gravatar.setImageUrl(GravatarHelper.getGravatarUrl(cursor.getString(authorEmail_index)),
            new ImageLoader(mRequestQuery, new BitmapLruCache(mContext)));

    return convertView;
}

From source file:com.undatech.opaque.dialogs.SelectTextElementFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    android.util.Log.e(TAG, "onCreateView called");

    XmlPullParser parser = getResources().getXml(R.layout.textelement);
    AttributeSet attributes = Xml.asAttributeSet(parser);

    // Set title for this dialog
    getDialog().setTitle(title);//from w ww  .j  a  v  a 2s  .c  om

    View v = inflater.inflate(R.layout.select_text, container, false);

    verticalLayout = (LinearLayout) v.findViewById(R.id.verticalLayout);
    ListIterator<String> iter = strings.listIterator();
    while (iter.hasNext()) {
        android.util.Log.e(TAG, "Adding element to dialog");
        String string = iter.next();
        TextView element = new TextView(v.getContext(), attributes);
        element.setText(string);
        element.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25.f);
        element.setPadding(40, 20, 40, 20);
        element.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SelectTextElementFragment.this.selected = ((TextView) v).getText().toString();
                SelectTextElementFragment.this.dismiss();
            }
        });
        verticalLayout.addView(element);
    }

    return v;
}

From source file:com.android.settings.widget.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();

    for (int i = 0; i < adapter.getCount(); i++) {
        final TextView tabTitleView = (TextView) mLayoutInflater.inflate(R.layout.sliding_tab_title_view,
                mTitleView, false);/*ww  w . j  av a  2  s.c o  m*/

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setOnClickListener(this);

        mTitleView.addView(tabTitleView);
        tabTitleView.setSelected(i == mViewPager.getCurrentItem());
    }
}

From source file:com.italankin.dictionary.ui.translation.TranslationActivity.java

/**
 * Add separate view for every attribute in array.
 *
 * @param parent     a parent view group to which views will be added
 * @param attributes array of attributes
 *///from   www.  j  a v  a2  s  .c  om
private void addViewsForAttributes(ViewGroup parent, Attribute[] attributes) {
    LayoutInflater inflater = getLayoutInflater();
    TextView view;
    for (Attribute a : attributes) {
        view = (TextView) inflater.inflate(R.layout.item_translation_text, parent, false);
        view.setText(a.text);
        view.setOnClickListener(this);
        view.setOnLongClickListener(this);
        parent.addView(view);
    }
}

From source file:com.survivingwithandroid.pegboard1.DreamPinsActivity.java

@Override
public void onSaveSelected() {
    closeMenu();/*from   w ww  .  j a  v  a 2  s . c  o m*/

    LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inf.inflate(R.layout.popsave_layout, null, false);

    final PopupWindow pw = new PopupWindow(v);
    pw.setFocusable(true);
    pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);

    final EditText edt = (EditText) v.findViewById(R.id.edtFileName);

    TextView saveTxt = (TextView) v.findViewById(R.id.dlgSave);
    TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel);
    cancelTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    saveTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            Bitmap b = pinTableFrag.createBitmap();
            try {
                ///////////////
                ImageUtility.saveImage(b, edt.getEditableText().toString(), DreamPinsActivity.this);
                ///////////////

            } catch (SaveFileException sfe) {
                Toast.makeText(DreamPinsActivity.this, getResources().getText(R.string.msgSaveFileError),
                        Toast.LENGTH_LONG).show();
            }
        }
    });

    pw.showAtLocation(v, Gravity.CENTER, 0, 0);

}

From source file:com.bordengrammar.bordengrammarapp.HomeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View myInflatedView = inflater.inflate(R.layout.fragment_home, container, false);
    GoogleMap map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    ut.logIt("1");
    try {//from  w w w .ja  va2 s . com
        Marker borden = map.addMarker(new MarkerOptions().position(BORDEN).snippet("This is where we are")
                .title("Borden Grammar School")
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));
        map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
        map.setMyLocationEnabled(true);
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(BORDEN, 15));
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    assert myInflatedView != null;
    TextView t = (TextView) myInflatedView.findViewById(R.id.tweet);
    //t.setText('"' + readPrefs("twitter") + '"');
    if (!readPrefs("link").isEmpty()) {
        t.setText('"' + readPrefs("twitter") + '"' + " - View Link");
        t.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity().getApplicationContext(), LinkActivity.class);
                intent.putExtra("link", readPrefs("link"));
                startActivity(intent);
            }
        });
    } else {

    }
    TextView t1;

    t1 = (TextView) myInflatedView.findViewById(R.id.date);
    String t1source = "<b>" + "&#64;" + "bordengrammar" + "</b>" + " | " + readPrefs("twittertime");
    t1.setText(Html.fromHtml(t1source));

    TextView info = (TextView) myInflatedView.findViewById(R.id.info);
    String sourceString = "<b>" + "Borden Grammar School" + "</b> "
            + "is a selective boy's grammar school in Sittingbourne, with a fierce commitment to educate, inspire and prepare students academically and socially";
    info.setText(Html.fromHtml(sourceString));

    //now for contact stuff

    return myInflatedView;
}

From source file:com.frozendevs.periodictable.view.ViewPagerTabs.java

private void addTab(CharSequence tabTitle, final int position) {
    final TextView textView = new TextView(getContext());
    textView.setText(tabTitle);/*from  w ww.  ja v  a2  s  .  co m*/
    textView.setGravity(Gravity.CENTER);
    textView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPager.setCurrentItem(getRtlPosition(position));
        }
    });

    /* We don't need this as far as we use text tabs only
    textView.setOnLongClickListener(new OnTabLongClickListener(position));*/

    // Assign various text appearance related attributes to child views.
    if (mTextStyle > 0) {
        textView.setTypeface(textView.getTypeface(), mTextStyle);
    }
    if (mTextSize > 0) {
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
    }
    if (mTextColor != null) {
        textView.setTextColor(mTextColor);
    }
    if (mTextBackground > 0) {
        textView.setBackgroundResource(mTextBackground);
    }
    textView.setText(
            textView.getText().toString().toUpperCase(getContext().getResources().getConfiguration().locale));
    textView.setPadding(mSidePadding, 0, mSidePadding, 0);
    mTabStrip.addView(textView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
    // Default to the first child being selected
    if (position == 0) {
        mPrevSelected = 0;
        textView.setSelected(true);
    }
}