List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:asia.utopia.musicoff.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from ww w . j a v a 2 s . c o m*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.example.helloandroid.animation.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w ww. ja va2 s. c om tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.google.android.gcm.demo.ui.GroupsFragment.java
@Override public void refresh() { float density = getActivity().getResources().getDisplayMetrics().density; SimpleArrayMap<String, Sender> senders = mSenders.getSenders(); LinearLayout sendersList = new LinearLayout(getActivity()); sendersList.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < senders.size(); i++) { Sender sender = senders.valueAt(i); if (sender.groups.size() > 0) { LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon); TextView senderText = (TextView) senderRow.findViewById(R.id.widget_itbr_text); senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE); senderIcon.setImageResource(R.drawable.cloud_googblue); senderIcon.setPadding(0, 0, (int) (8 * density), 0); senderText.setText(getString(R.string.groups_sender_id, sender.senderId)); sendersList.addView(senderRow); for (DeviceGroup deviceGroup : sender.groups.values()) { LinearLayout row = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon); TextView label = (TextView) row.findViewById(R.id.widget_itbr_text); Button button = (Button) row.findViewById(R.id.widget_itbr_button); icon.setImageResource(R.drawable.group_grey600); label.setText(deviceGroup.notificationKeyName); label.setBackgroundResource(selectableBackgroundResource); label.setTag(R.id.tag_action, ACTION_OPEN_GROUP); label.setTag(R.id.tag_senderid, sender.senderId); label.setTag(R.id.tag_group, deviceGroup.notificationKeyName); label.setOnClickListener(this); button.setText(R.string.groups_delete); button.setTag(R.id.tag_action, ACTION_DELETE_GROUP); button.setTag(R.id.tag_senderid, sender.senderId); button.setTag(R.id.tag_group, deviceGroup.notificationKeyName); button.setOnClickListener(this); row.setPadding((int) (16 * density), 0, 0, 0); sendersList.addView(row); }//from w w w. ja v a 2 s . c om } } if (sendersList.getChildCount() == 0) { TextView noTokens = new TextView(getActivity()); noTokens.setText(getString(R.string.groups_no_groups_available)); noTokens.setTypeface(null, Typeface.ITALIC); sendersList.addView(noTokens); } FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.groups_list_wrapper); topicsView.removeAllViews(); topicsView.addView(sendersList); }
From source file:joshuamgoodwin.gmail.com.ohiolegalaidassistant.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawerlayout); mTitle = mDrawerTitle = getTitle();//from www . ja va2 s . c o m mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ExpandableListView) findViewById(R.id.left_drawer_list); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); setDrawer(); // Listview on child click listener mDrawerList.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { String child = listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition); //String child = list.get(childPosition); selectItem(listDataHeader.get(groupPosition), groupPosition, childPosition, child); return false; } }); // Listview Group expanded listener mDrawerList.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { if (lastExpanded != -1) { if (lastExpanded != groupPosition) mDrawerList.collapseGroup(lastExpanded); } lastExpanded = groupPosition; } }); // Listview Group collasped listener mDrawerList.setOnGroupCollapseListener(new OnGroupCollapseListener() { @Override public void onGroupCollapse(int groupPosition) { } }); TextView about = (TextView) findViewById(R.id.about_drawer); about.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { selectItem("About", 0, 0, ""); } }); TextView license = (TextView) findViewById(R.id.license_drawer); license.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { selectItem("License", 0, 0, ""); } }); // mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, // host Activity mDrawerLayout, // DrawerLayout object //R.drawable.ic_drawer, // nav drawer image to replace 'Up' caret R.string.drawer_open, // "open drawer" description for accessibility R.string.drawer_close // "close drawer" description for accessibility ) { public void onDrawerClosed(View view) { } public void onDrawerOpened(View drawerView) { } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem("Welcome", 0, 0, ""); } /* } else { setTitle(savedInstanceState.getCharSequence("mTitle")); }*/ // changelog on start SharedPreferences prefs = getPreferences(MODE_PRIVATE); boolean test = prefs.getBoolean("third", true); if (test) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(Html.fromHtml(getString(R.string.changes))).setPositiveButton("OK", null) .setTitle("What's New!"); AlertDialog dialog = builder.create(); dialog.show(); // make sure it only runs first time SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("third", false); editor.commit(); } getSupportActionBar().setTitle(R.string.app_name); }
From source file:com.android.argb.edhlc.Utils.java
public static void createAboutDialog(final View view) { @SuppressLint("InflateParams") View aboutDialog = LayoutInflater.from(view.getContext()).inflate(R.layout.dialog_about, null); TextView version = (TextView) aboutDialog.findViewById(R.id.version); TextView aChart = (TextView) aboutDialog.findViewById(R.id.thirdPartyAChartEngine); TextView crop = (TextView) aboutDialog.findViewById(R.id.thirdPartyCrop); TextView picker = (TextView) aboutDialog.findViewById(R.id.thirdColorPicker); TextView apache = (TextView) aboutDialog.findViewById(R.id.apache); try {//from w w w . ja v a2s. co m PackageInfo pInfo = pInfo = view.getContext().getPackageManager() .getPackageInfo(view.getContext().getPackageName(), 0); version.setText(pInfo.versionName); } catch (PackageManager.NameNotFoundException e) { version.setText(""); } aChart.setText(Html.fromHtml("<u>AChartEngine</u>")); aChart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uriUrl = Uri.parse("http://www.achartengine.org/index.html"); Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); view.getContext().startActivity(launchBrowser); } }); crop.setText(Html.fromHtml("<u>Android CropImage</u>")); crop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uriUrl = Uri.parse("https://github.com/lvillani/android-cropimage"); Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); view.getContext().startActivity(launchBrowser); } }); picker.setText(Html.fromHtml("<u>Android Stock Color Picker Library</u>")); picker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uriUrl = Uri.parse("https://github.com/woalk/android-colorpicker"); Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); view.getContext().startActivity(launchBrowser); } }); apache.setText(Html.fromHtml( "Licensed under Apache License v2.0.<br>You can obtain a copy of the license <u>here</u>.")); apache.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uriUrl = Uri.parse("http://www.apache.org/licenses/LICENSE-2.0"); Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); view.getContext().startActivity(launchBrowser); } }); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(view.getContext()); alertDialogBuilder.setView(aboutDialog); alertDialogBuilder.setTitle(""); alertDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialogBuilder.setNeutralButton("MORE", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); AlertDialog.Builder alertDialogBuilder2 = new AlertDialog.Builder(view.getContext()); alertDialogBuilder2 .setView(LayoutInflater.from(view.getContext()).inflate(R.layout.dialog_about2, null)); alertDialogBuilder2.setTitle(""); alertDialogBuilder2.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialogBuilder2.setNegativeButton("BACK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createAboutDialog(view); } }); final AlertDialog alertDialog2 = alertDialogBuilder2.create(); alertDialog2.show(); } }); final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:com.todoroo.astrid.actfm.ActFmLoginActivity.java
protected void setupTermsOfService(TextView tos) { OnClickListener showTosListener = new OnClickListener() { @Override/*from w w w . j a v a2 s.c om*/ public void onClick(View v) { Eula.showEulaBasic(ActFmLoginActivity.this); } }; tos.setOnClickListener(showTosListener); String tosBase = getString(R.string.welcome_login_tos_base); String tosLink = getString(R.string.welcome_login_tos_link); SpannableString link = getLinkStringWithCustomInterval(tosBase, tosLink, tosBase.length() + 2, -1, showTosListener); tos.setText(link); }
From source file:com.yibu.headmaster.lib.PagerSliding.PagerSlidingTab.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);// ww w . j a v a 2s .c om tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position, false); } }); tabsContainer.addView(tab); }
From source file:edu.cwru.apo.Directory.java
private void loadTable() { ProgressDialog progDialog = ProgressDialog.show(this, "Loading", "Please Wait", false); userTable.removeAllViews();/*from ww w .ja va2 s. c o m*/ Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, null, null, null, null, "first"); String rowText = ""; TableRow row; TextView text; if (!results.moveToFirst()) return; while (!results.isAfterLast()) { String phoneNumber = removeNonDigits(results.getString(3)); if (!(phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null"))) { rowText = results.getString(0) + " " + results.getString(1) + " [" + results.getString(2) + "]"; row = new TableRow(this); text = new TextView(this); row.setPadding(0, 5, 0, 5); text.setClickable(true); text.setOnClickListener(this); //text.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); text.setText(rowText); userTable.addView(row); row.addView(text); } results.moveToNext(); } progDialog.cancel(); }
From source file:com.hanyao.passwordmanager.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); instance = this; findViews();//from w ww .jav a2 s . c o m toolbar.setLogo(R.mipmap.ic_launcher); toolbar.setTitle(this.getString(R.string.app_name)); setSupportActionBar(toolbar); toolbar.setOnMenuItemClickListener(onMenuItemClick); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.open, R.string.close) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); } }; mDrawerToggle.syncState(); mDrawerLayout.setDrawerListener(mDrawerToggle); SharedPreferences preferences = getSharedPreferences("data", MODE_PRIVATE); preferences.getString("userName", "null"); if (preferences.getString("userName", "null").equals("null")) { Intent intent = new Intent(MainActivity.this, LocalUserRegistActivity.class); startActivity(intent); } else { Intent intent = new Intent(MainActivity.this, CheckPowerActivity.class); startActivity(intent); } //?? TextView change = (TextView) findViewById(R.id.change_password_item); TextView help = (TextView) findViewById(R.id.help_item); TextView about = (TextView) findViewById(R.id.about_item); TextView input = (TextView) findViewById(R.id.input_item); TextView output = (TextView) findViewById(R.id.output_item); TextView agreement = (TextView) findViewById(R.id.agreement_item); change.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, ChangePasswordActivity.class); startActivity(intent); } }); agreement.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ShowInformationActivity.actionShowInformationActivity(MainActivity.this, "<h1>??</h1>\n" + "<p>????????????</p>\n" + "<p>??</p>\n" + "<p>????</p>\n" + "<p>???????</p>\n" + "<p>????</p>\n" + "<p>????</p>\n" + "<p>?</p>\n" + "<p>??</p>\n" + "<p>???????<p/>\n" + "<p>????</p>"); } }); help.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ShowInformationActivity.actionShowInformationActivity(MainActivity.this, "<h1>???</h1><p>???????</p><h1>????</h1><p>?????????????????????</p>"); } }); about.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ShowInformationActivity.actionShowInformationActivity(MainActivity.this, "<h1></h1>\n" + "<p>1.1.0</p>\n" + "<p>??https://github.com/yilihjy/PasswordManager??</p>\n" + "<p>Copyright yilihjy</p>\n" + "<p>Licensed under the Apache License, Version 2.0 (the \"License\");you may not use this file except in compliance with the License.You may obtain a copy of the License at</p>\n" + "<p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "<p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</p>\n" + "<h2>??</h2>\n" + "<p>GridPasswordView</p>\n" + "<p>Jungerr</p>\n" + "<p>??</p>\n" + "<p>Copyright 2015 jungly</p>\n" + "<p>Licensed under the Apache License, Version 2.0 (the \"License\");you may not use this file except in compliance with the License.You may obtain a copy of the License at</p>\n" + "<p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "<p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions and limitations under the License.</p>\n" + "<p>?https://github.com/Jungerr/GridPasswordView</p>"); } }); output.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this); dialog.setTitle("??"); dialog.setMessage("???"); dialog.setCancelable(false); dialog.setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new OutputTask().execute(); } }); dialog.setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); } }); input.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, InputActivity.class); startActivity(intent); } }); }
From source file:android.melbournehistorymap.MapsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); Typeface iconFont = FontManager.getTypeface(getApplicationContext(), FontManager.FONTAWESOME); FontManager.markAsIconContainer(findViewById(R.id.main_content), iconFont); Typeface medFont = FontManager.getTypeface(getApplicationContext(), FontManager.ROBO_MEDIUM); FontManager.markAsIconContainer(findViewById(R.id.placeDescription), medFont); FontManager.markAsIconContainer(findViewById(R.id.placeVic), medFont); FontManager.markAsIconContainer(findViewById(R.id.fullArticle), medFont); Typeface regFont = FontManager.getTypeface(getApplicationContext(), FontManager.ROBO_REG); FontManager.markAsIconContainer(findViewById(R.id.expPlaceVic), regFont); Typeface thinFont = FontManager.getTypeface(getApplicationContext(), FontManager.ROBO_THIN); //FontManager.markAsIconContainer(findViewById(R.id.placeDistance), thinFont); FontManager.markAsIconContainer(findViewById(R.id.expPlaceDistance), thinFont); FontManager.markAsIconContainer(findViewById(R.id.wikiLicense), thinFont); Typeface lightFont = FontManager.getTypeface(getApplicationContext(), FontManager.ROBO_LIGHT); FontManager.markAsIconContainer(findViewById(R.id.expPlaceDistance), lightFont); FontManager.markAsIconContainer(findViewById(R.id.photoAttribute), lightFont); FontManager.markAsIconContainer(findViewById(R.id.expPhotoAttribute), lightFont); Typeface boldFont = FontManager.getTypeface(getApplicationContext(), FontManager.ROBO_BOLD); FontManager.markAsIconContainer(findViewById(R.id.expPlaceTitle), boldFont); FontManager.markAsIconContainer(findViewById(R.id.placeTitle), boldFont); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); TextView fab = (TextView) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override/*from w w w .java 2 s .c o m*/ public void onClick(View view) { // Snackbar.make(view, "Show history", Snackbar.LENGTH_LONG) // .setAction("Action", null).show(); expandTile(view); } }); Bundle extras = getIntent().getExtras(); CurrLat = extras.getString("CLoc_Lat"); CurrLong = extras.getString("CLoc_Long"); smallTile = (RelativeLayout) findViewById(R.id.tile); expandedTile = (RelativeLayout) findViewById(R.id.expandedTile); //Initiliase connection to Google Places API mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(Places.GEO_DATA_API).addApi(LocationServices.API) .addApi(Places.PLACE_DETECTION_API).build(); }