List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.happysanta.vkspy.Fragments.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = getActivity();// w w w.java 2 s.co m if (savedInstanceState != null && UberFunktion.loading) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(context.getString(R.string.durov_function_activating_message)); UberFunktion.putNewDialogWindow(dialog); dialog.show(); } View rootView = inflater.inflate(R.layout.fragment_main, null); View happySanta = inflater.inflate(R.layout.main_santa, null); TextView happySantaText = (TextView) happySanta.findViewById(R.id.happySantaText); happySantaText.setText(Html.fromHtml(context.getString(R.string.app_description))); TextView happySantaLink = (TextView) happySanta.findViewById(R.id.happySantaLink); happySantaLink.setText(Html.fromHtml("vk.com/<b>happysanta</b>")); happySantaLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vk.com/happysanta")); startActivity(browserIntent); } }); happySanta.setOnClickListener(new View.OnClickListener() { int i = 1; @Override public void onClick(View v) { if (i < 10) i++; else { i = 0; File F = Logs.getFile(); Uri U = Uri.fromFile(F); Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_STREAM, U); startActivity(Intent.createChooser(i, "What should we do with logs?")); } } }); SharedPreferences longpollPreferences = context.getSharedPreferences("longpoll", Context.MODE_MULTI_PROCESS); boolean longpollStatus = longpollPreferences.getBoolean("status", true); /*Bitmap tile = BitmapFactory.decodeResource(context.getResources(), R.drawable.underline); BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(context.getResources(), tile); tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT); //tiledBitmapDrawable.setTileModeY(Shader.TileMode.REPEAT); santaGroundView.setBackgroundDrawable(tiledBitmapDrawable); BitmapDrawable bitmap = new BitmapDrawable(BitmapFactory.decodeResource( getResources(), R.drawable.underline2)); bitmap.setTileModeX(Shader.TileMode.REPEAT); */ LinearLayout layout = (LinearLayout) happySanta.findViewById(R.id.line); Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); // deprecated for (int i = 0; width % (341 * i + 1) < width; i++) { layout.addView(new ImageView(context) { { setImageResource(R.drawable.underline2); setLayoutParams(new ViewGroup.LayoutParams(341, Helper.convertToDp(4))); setScaleType(ScaleType.CENTER_CROP); } }); } ListView preferencesView = (ListView) rootView.findViewById(R.id.preference); preferencesView.addHeaderView(happySanta, null, false); ArrayList<PreferenceItem> preferences = new ArrayList<PreferenceItem>(); /* preferences.add(new PreferenceItem(getUberfunction(), getUberfunctionDescription()) { @Override public void onClick() { if(UberFunktion.loading) { ProgressDialog dialog = new ProgressDialog(context); dialog.setMessage(context.getString(R.string.durov_function_activating_message)); UberFunktion.putNewDialogWindow(dialog); dialog.show(); return; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog selector; View durov = getActivity().getLayoutInflater().inflate(R.layout.durov, null); SharedPreferences durovPreferences = context.getSharedPreferences("durov", Context.MODE_MULTI_PROCESS); boolean updateOnly = durovPreferences.getBoolean("loaded", false); if(updateOnly) ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_function_activated); if(Memory.users.getById(1)!=null && !updateOnly) { builder.setTitle(R.string.durov_joke_title); ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_joke_message); ( durov.findViewById(R.id.cat)).setVisibility(View.VISIBLE); builder.setNegativeButton(R.string.durov_joke_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BugSenseHandler.sendEvent("? ? "); } }); BugSenseHandler.sendEvent("DUROV FRIEND CATCHED!!1"); }else{ builder.setTitle(R.string.durov_start_title); ( durov.findViewById(R.id.photo)).setVisibility(View.VISIBLE); ImageLoader.getInstance().displayImage("http://cs9591.vk.me/v9591001/70/VPSmUR954fQ.jpg",(ImageView) durov.findViewById(R.id.photo)); builder. setPositiveButton(updateOnly ? R.string.durov_start_update : R.string.durov_start_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BugSenseHandler.sendEvent(" "); ProgressDialog uberfunctionDialog = ProgressDialog.show(getActivity(), context.getString(R.string.durov_function_activating_title), context.getString(R.string.durov_function_activating_message), true, false); UberFunktion.initialize(uberfunctionDialog); } }); builder.setNegativeButton(R.string.durov_start_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Intent browserIntent = new Intent( Intent.ACTION_VIEW, Uri.parse("https://vk.com/id1") ); startActivity(browserIntent); }catch(Exception exp){ AlertDialog.Builder errorShower = new AlertDialog.Builder(getActivity()); if (exp instanceof ActivityNotFoundException) { errorShower.setTitle(R.string.error); errorShower.setMessage(R.string.no_browser); } else { errorShower.setTitle(R.string.error); errorShower.setMessage(R.string.unknown_error); } errorShower.show(); } BugSenseHandler.sendEvent("? ? "); } }); } builder.setView(durov); selector = builder.create(); selector.show(); } }); */ preferences.add(new ToggleablePreferenceItem(getEnableSpy(), null, longpollStatus) { @Override public void onToggle(Boolean isChecked) { longpollToggle(isChecked); } }); preferences.add(new PreferenceItem(getAdvancedSettings()) { @Override public void onClick() { startActivity(new Intent(context, SettingsActivity.class)); } }); preferences.add(new PreferenceItem(getAbout()) { @Override public void onClick() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final AlertDialog aboutDialog; builder.setTitle(R.string.app_about).setCancelable(true) .setPositiveButton(R.string.app_about_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); View aboutView = getActivity().getLayoutInflater().inflate(R.layout.about, null); TextView aboutDescription = (TextView) aboutView.findViewById(R.id.description); aboutDescription.setText(Html.fromHtml(getResources().getString(R.string.app_about_description))); aboutDescription.setMovementMethod(LinkMovementMethod.getInstance()); aboutView.findViewById(R.id.license).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(context, InfoActivity.class); startActivity(browserIntent); } }); builder.setView(aboutView); aboutDialog = builder.create(); aboutDialog.setCanceledOnTouchOutside(true); aboutDialog.show(); } }); preferencesView.setAdapter(new PreferenceAdapter(context, preferences)); return rootView; }
From source file:com.yahala.ui.GroupCreateFinalActivity.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.group_create_menu, menu); SupportMenuItem doneItem = (SupportMenuItem) menu.findItem(R.id.done_menu_item); TextView doneTextView = (TextView) doneItem.getActionView().findViewById(R.id.done_button); doneTextView.setText(LocaleController.getString("Done", R.string.Done)); doneTextView.setOnClickListener(new View.OnClickListener() { @Override/* ww w . jav a2s. c om*/ public void onClick(View view) { /* if (donePressed || parentActivity == null) { return; } if (nameTextView.getText().length() == 0) { return; } donePressed = true; if (avatarUpdater.uploadingAvatar != null) { createAfterUpload = true; } else { progressDialog = new ProgressDialog(parentActivity); progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); final long reqId = MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar); progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ConnectionsManager.getInstance().cancelRpc(reqId, true); donePressed = false; try { dialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); progressDialog.show(); }*/ } }); }
From source file:fi.mikuz.boarder.gui.internet.Uploads.java
private void boardUploader(final InternetFullBoard board, final int phpOperation) { LayoutInflater inflater = (LayoutInflater) Uploads.this.getSystemService(LAYOUT_INFLATER_SERVICE); final View layout = inflater.inflate(R.layout.internet_uploads_alert_upload_board, (ViewGroup) findViewById(R.id.alert_settings_root)); TextView wikiLink = (TextView) layout.findViewById(R.id.wikiLink); wikiLink.setText("\n Guide here!\n\n"); wikiLink.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Mikuz/Boarder/wiki/Uploading-guide")); startActivity(browserIntent); }// w ww . j ava 2 s . c om }); AlertDialog.Builder builder = new AlertDialog.Builder(Uploads.this); builder.setView(layout); builder.setTitle("Upload board"); refreshUploadAlertBoard(layout, board); final Button sendButton = (Button) layout.findViewById(R.id.sendButton); sendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mWaitDialog = new TimeoutProgressDialog(Uploads.this, "Waiting for response", TAG, false); HashMap<String, String> sendList = getSendList(layout, board, phpOperation); new ConnectionManager(Uploads.this, InternetMenu.mUploadBoardURL, sendList); } }); final Button previewButton = (Button) layout.findViewById(R.id.previewButton); previewButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { HashMap<String, String> sendList = getSendList(layout, board, phpOperation); // Simulate a board from web sendList.put(InternetMenu.BOARD_ID_KEY, "-1"); sendList.put(InternetMenu.RATING_KEY, "0"); sendList.put(InternetMenu.USERNAME_KEY, "Preview"); JSONObject databaseValues = new JSONObject(); if (sendList != null) { for (String key : sendList.keySet()) { try { databaseValues.put(key, sendList.get(key)); } catch (JSONException e) { Log.e(TAG, "Error putting '" + key + "' to JSONObject as database value"); } } } JSONArray jArray = new JSONArray(); jArray.put(databaseValues); JSONObject fakeMessage = null; try { fakeMessage = new JSONObject(); fakeMessage.put(ConnectionUtils.returnData, jArray); } catch (JSONException e) { Log.e(TAG, "Error constructing fake json message", e); } Intent i = new Intent(Uploads.this, DownloadBoard.class); XStream xstream = new XStream(); i.putExtra(DownloadBoard.SHOW_KEY, DownloadBoard.SHOW_PREVIEW_BOARD); i.putExtra(DownloadBoard.JSON_KEY, xstream.toXML(fakeMessage)); startActivity(i); } }); builder.show(); }
From source file:com.app.blockydemo.content.bricks.ChangeVariableBrick.java
@Override public View getView(final Context context, int brickId, BaseAdapter baseAdapter) { if (animationState) { return view; }/*from w w w. j a va2s . c o m*/ view = View.inflate(context, R.layout.brick_change_variable_by, null); view = getViewWithAlpha(alphaValue); setCheckboxView(R.id.brick_change_variable_checkbox); final Brick brickInstance = this; checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checked = isChecked; adapter.handleCheck(brickInstance, isChecked); } }); TextView prototypeText = (TextView) view.findViewById(R.id.brick_change_variable_prototype_view); TextView textField = (TextView) view.findViewById(R.id.brick_change_variable_edit_text); prototypeText.setVisibility(View.GONE); variableFormula.setTextFieldId(R.id.brick_change_variable_edit_text); variableFormula.refreshTextField(view); textField.setVisibility(View.VISIBLE); textField.setOnClickListener(this); Spinner variableSpinner = (Spinner) view.findViewById(R.id.change_variable_spinner); UserVariableAdapter userVariableAdapter = ProjectManager.getInstance().getCurrentProject() .getUserVariables().createUserVariableAdapter(context, sprite); UserVariableAdapterWrapper userVariableAdapterWrapper = new UserVariableAdapterWrapper(context, userVariableAdapter); userVariableAdapterWrapper.setItemLayout(android.R.layout.simple_spinner_item, android.R.id.text1); variableSpinner.setAdapter(userVariableAdapterWrapper); if (!(checkbox.getVisibility() == View.VISIBLE)) { variableSpinner.setClickable(true); variableSpinner.setEnabled(true); } else { variableSpinner.setClickable(false); variableSpinner.setFocusable(false); } setSpinnerSelection(variableSpinner, null); variableSpinner.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (((Spinner) view).getSelectedItemPosition() == 0 && ((Spinner) view).getAdapter().getCount() == 1) { NewVariableDialog dialog = new NewVariableDialog((Spinner) view); dialog.addVariableDialogListener(ChangeVariableBrick.this); dialog.show(((FragmentActivity) view.getContext()).getSupportFragmentManager(), NewVariableDialog.DIALOG_FRAGMENT_TAG); return true; } } return false; } }); variableSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0 && ((UserVariableAdapterWrapper) parent.getAdapter()).isTouchInDropDownView()) { NewVariableDialog dialog = new NewVariableDialog((Spinner) parent); dialog.addVariableDialogListener(ChangeVariableBrick.this); dialog.show(((FragmentActivity) view.getContext()).getSupportFragmentManager(), NewVariableDialog.DIALOG_FRAGMENT_TAG); } ((UserVariableAdapterWrapper) parent.getAdapter()).resetIsTouchInDropDownView(); userVariable = (UserVariable) parent.getItemAtPosition(position); adapterView = parent; } @Override public void onNothingSelected(AdapterView<?> arg0) { userVariable = null; } }); return view; }
From source file:com.mobicage.rogerthat.AbstractHomeActivity.java
private void initUI() { mBadgeMessages = (TextView) findViewById(R.id.badge_0x0); for (ItemDef i : getItemDefs()) { final ImageView icon = (ImageView) findViewById(i.iconId); icon.setOnClickListener(i.clickListener); final TextView label = (TextView) findViewById(i.labelId); label.setOnClickListener(i.clickListener); label.setText(i.labelTextId);/* w w w. j av a 2 s . com*/ } loadQR(); }
From source file:com.konsula.app.gcm.MyGcmListenerService.java
private void handleGCM(Bundle bundle) { try {/* w w w . j a v a 2 s . c om*/ Bundle data = bundle; String message = data.getString(TAG_MESSAGE, ""); final String doc_name = data.getString(TAG_DOC_NAME, ""); final String schedule = data.getString(TAG_SCHEDULE, ""); final String specialization = data.getString(TAG_SPECIALIZATION, ""); final String status = data.getString(TAG_STATUS, ""); String tele_uuid = data.getString(TAG_TELE_UUID, ""); String page = data.getString(TAG_PAGE, ""); String type = data.getString(TAG_TYPE, ""); if (type.equals("dialog")) { if (page.equals("teledoc-confirmed")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_confirm, null); TextView textViewname = (TextView) invoiceDetail.findViewById(R.id.tvNamaDokter); TextView textViewspeciality = (TextView) invoiceDetail.findViewById(R.id.etSpeciality); TextView textViewdate = (TextView) invoiceDetail.findViewById(R.id.tvDate); TextView textViewstatus = (TextView) invoiceDetail.findViewById(R.id.text_status); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textViewname.setText(doc_name); textViewspeciality.setText(specialization); textViewdate.setText(schedule); textViewstatus.setText(status.toUpperCase()); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } if (page.equals("teledoc-cancel")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_cancel_confirm, null); TextView textView = (TextView) invoiceDetail.findViewById(R.id.message); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textView.setText(getResources().getString(R.string.text_teledoc_cancel)); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } if (page.equals("teledoc-reschedule")) { CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(this, getResources().getColor(R.color.green_xxl)); View invoiceDetail = LayoutInflater.from(this).inflate(R.layout.dialog_teledoc_cancel_confirm, null); TextView textView = (TextView) invoiceDetail.findViewById(R.id.message); TextView btnCancel = (TextView) invoiceDetail.findViewById(R.id.positive_button); btnCancel.setBackgroundColor(getResources().getColor(R.color.green_xxl)); btnCancel.setText(getResources().getString(R.string.mdtp_ok)); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); textView.setText(getResources().getString(R.string.text_reschedule_information)); builder.setView(invoiceDetail); builder.setTitle(getResources().getString(R.string.title_teledokter)); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { // TODO Auto-generated method stub Dialog d = ((Dialog) dialog); int dividerId = d.getContext().getResources().getIdentifier("android:id/titleDivider", null, null); View divider = d.findViewById(dividerId); if (divider != null) { divider.setBackgroundColor(getResources().getColor(R.color.green_xxl)); } } }); dialog.show(); } } else if (type.equals("intent") && (page.equals("teledoc-confirmation-reschedule"))) { Intent intent = new Intent(this, TeledocRescheduleActivity.class); intent.putExtra(TeledocRescheduleActivity.TAG_TELE_UUID, tele_uuid); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_NAME, doc_name); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_SPECIALIZATION, specialization); intent.putExtra(TeledocRescheduleActivity.TAG_DOC_SCHEDULE, schedule); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } catch (Exception e) { Log.e("ee", e.getMessage()); Log.e("ee", String.valueOf(e)); } }
From source file:de.mdxdave.materialbreadcrumbsnavigation.MaterialBreadcrumbsNavigation.java
private void addItem(final NavigationItem item, int position, boolean isRoot, boolean setActive) { LayoutInflater vi = (LayoutInflater) context.getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = vi.inflate(R.layout.item_view, null); int last;//from w w w .j a va2 s. c o m if (isRoot) { last = 0; list.add(item); } else if (position == -1) { last = viewGroup.getChildCount(); last = (last < 0) ? 0 : last; list.add(item); } else { last = position; list.set(position, item); } final TextView textView = (TextView) v.findViewById(R.id.breadcrumbnav_textView); textView.setTextColor(darkenColor(textColor)); textView.setText(item.getTitle().toUpperCase()); item.setId(last); final int finalLast = last; textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { setActive(finalLast, false, true); } }); ImageView imageView = (ImageView) v.findViewById(R.id.breadcrumbnav_imageView); imageView.setColorFilter(indicatorColor, PorterDuff.Mode.MULTIPLY); // Padding and root item if (isRoot) { imageView.setVisibility(View.GONE); int padding_left = 48; int padding_right = 12; int padding = 18; final float scale = getResources().getDisplayMetrics().density; int padding_left_px = (int) (padding_left * scale + 0.5f); int padding_right_px = (int) (padding_right * scale + 0.5f); int padding_px = (int) (padding * scale + 0.5f); textView.setPadding(padding_left_px, padding_px, padding_right_px, padding_px); } // Scroll to end final int finalLast1 = last; horizontalScrollView.post(new Runnable() { @Override public void run() { if (finalLast1 == viewGroup.getChildCount()) horizontalScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT); } }); viewGroup.addView(v, last, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); if (setActive || getCurrent() == position || list.size() == 0) setActive(last, true); }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
@Override public void onCreate(Bundle savedInstanceState) { ThemeUtils.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.about);// w w w .j a va 2 s . co m ThemeUtils.fixSmartBar(this); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { getActionBar().setDisplayHomeAsUpEnabled(true); } WebView webView = (WebView) findViewById(R.id.webview); webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); if ("zh".equals(Locale.getDefault().getLanguage())) { webView.loadUrl("file:///android_asset/about.zh.html"); } else { webView.loadUrl("file:///android_asset/about.en.html"); } setView(R.id.alipay, "com.eg.android.AlipayGphone"); if (hasPermission()) { setView(R.id.wechat, "com.tencent.mm"); } else { findViewById(R.id.wechat).setVisibility(View.GONE); } if (!setView(R.id.paypal, "com.paypal.android.p2pmobile")) { TextView paypal = (TextView) findViewById(R.id.paypal); paypal.setClickable(true); paypal.setOnClickListener(this); paypal.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(paypal.getCompoundDrawables()[1]), null, null); } if (setView(R.id.play, "com.android.vending")) { findViewById(R.id.play).setVisibility(View.GONE); checkDonate(); } donateView = findViewById(R.id.donate); if (BuildConfig.DONATE && TextUtils.isEmpty(LicenseUtils.getLicense(this))) { donateView.setVisibility(View.VISIBLE); } else { donateView.setVisibility(View.GONE); } retrieveInfo(); }
From source file:larry.baby.rain.common.view.TabPageIndicator.java
private void addTab(CharSequence text, int index) { Context context = getContext(); DisplayMetrics dm = context.getResources().getDisplayMetrics(); int padX = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 22, dm); int padY = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, dm); TextView tabView = new TextView(context); tabView.setBackgroundResource(R.drawable.vpi__tab_indicator); tabView.setPadding(padX, padY, padX, padY); tabView.setGravity(Gravity.CENTER);/*from ww w . ja va2 s.co m*/ tabView.setTextColor(0xfff3f3f3); tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); tabView.setTypeface(tabView.getTypeface(), Typeface.BOLD); tabView.setSingleLine(); tabView.setTag(index); tabView.setFocusable(true); tabView.setOnClickListener(this); tabView.setText(text); mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1)); }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripView.java
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = (ViewGroup) findViewById(R.id.suggestions_strip); mVoiceKey = (ImageButton) findViewById(R.id.suggestions_strip_voice_key); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mImportantNoticeStrip); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion)); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word);/*from w w w.j a va 2 s. c o m*/ final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); mDebugInfoViews.add(info); } mLayoutHelper = new SuggestionStripLayoutHelper(context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = (MoreSuggestionsView) mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res .getDimensionPixelOffset(R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector(context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey); keyboardAttr.recycle(); mVoiceKey.setImageDrawable(iconVoice); mVoiceKey.setOnClickListener(this); }