Java Code Examples for android.widget.ImageButton#setTag()
The following examples show how to use
android.widget.ImageButton#setTag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LibraryAdapter.java From TextFiction with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { View ret = convertView; if (ret == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); ret = inflater.inflate(R.layout.library_item, null); } TextView name = (TextView) ret.findViewById(R.id.gamename); ImageButton trash = (ImageButton) ret.findViewById(R.id.btn_delete); if (stripSuffix) { name.setText(FileUtil.basename(getItem(position))); } else { name.setText(getItem(position).getName()); } trash.setTag(getItem(position)); trash.setOnClickListener(this); return ret; }
Example 2
Source File: FormNavigationUI.java From commcare-android with Apache License 2.0 | 6 votes |
private static void setDoneState(ImageButton nextButton, Context context, final ClippingFrame finishButton, FormNavigationController.NavigationDetails details, ProgressBar progressBar) { if (nextButton.getTag() == null) { setFinishVisible(finishButton); } else if (!FormEntryConstants.NAV_STATE_DONE.equals(nextButton.getTag())) { nextButton.setTag(FormEntryConstants.NAV_STATE_DONE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { expandAndShowFinishButton(context, finishButton); } else { setFinishVisible(finishButton); } } progressBar.setProgressDrawable(context.getResources().getDrawable(R.drawable.progressbar_full)); progressBar.setProgress(details.totalQuestions); Log.i("Questions", "Form complete"); }
Example 3
Source File: TabletTabSwitcherLayout.java From ChromeLikeTabSwitcher with Apache License 2.0 | 6 votes |
/** * Animates the visibility of a tab's close button. * * @param viewHolder * The view holder, which holds a reference to the close button, whose visibility should * be animated, as an instance of the class {@link AbstractTabViewHolder}. The view * holder may not be null * @param show * True, if the close button should be shown, false otherwise */ private void animateCloseButtonVisibility(@NonNull final AbstractTabViewHolder viewHolder, final boolean show) { ImageButton closeButton = viewHolder.closeButton; Boolean visible = (Boolean) closeButton.getTag(R.id.tag_visibility); if (visible == null || visible != show) { closeButton.setTag(R.id.tag_visibility, show); if (closeButton.getAnimation() != null) { closeButton.getAnimation().cancel(); } ViewPropertyAnimator animation = closeButton.animate(); animation.setListener(createCloseButtonVisibilityAnimationListener(viewHolder, show)); animation.alpha(show ? 1 : 0); animation.setStartDelay(0); animation.setDuration(closeButtonVisibilityAnimationDuration); animation.start(); } }
Example 4
Source File: ButtonManager.java From Camera2 with Apache License 2.0 | 5 votes |
/** * Enables a button that has already been initialized. */ public void enableButton(int buttonId) { // If Camera Button is blocked, ignore the request. if (buttonId == BUTTON_CAMERA && mIsCameraButtonBlocked) { return; } ImageButton button; // Manual exposure uses a regular image button instead of a // MultiToggleImageButton, so it requires special handling. // TODO: Redesign ButtonManager's button getter methods into one method. if (buttonId == BUTTON_EXPOSURE_COMPENSATION) { button = getImageButtonOrError(buttonId); } else { button = getButtonOrError(buttonId); } if (!button.isEnabled()) { button.setEnabled(true); if (mListener != null) { mListener.onButtonEnabledChanged(this, buttonId); } } button.setTag(R.string.tag_enabled_id, buttonId); }
Example 5
Source File: EmotionManager.java From yiim_v2 with GNU General Public License v2.0 | 5 votes |
private ViewHolder instanceView(int position, int emoji) { ViewHolder viewHolder = new ViewHolder(); View rootView = null; int base_index = 0; int count = 0; if (emoji == EMOTION) { count = 8; base_index = position * count; rootView = LayoutInflater.from(mContext).inflate( R.layout.emotion_pager_item, null); } else { count = 21; base_index = position * count; rootView = LayoutInflater.from(mContext).inflate( R.layout.emotion_pager_classical_item, null); } viewHolder.emotionViews = new ArrayList<ImageButton>(); for (int i = 0; i < count; i++) { ImageButton view = (ImageButton) rootView.findViewById(mContext .getResources().getIdentifier("emo_" + (i + 1), "id", mContext.getPackageName())); view.setOnClickListener(this); view.setTag(String.valueOf(base_index + i)); viewHolder.emotionViews.add(view); } viewHolder.rootView = rootView; return viewHolder; }
Example 6
Source File: FormNavigationUI.java From commcare-android with Apache License 2.0 | 5 votes |
private static void setMoreQuestionsState(ImageButton nextButton, Context context, ClippingFrame finishButton, FormNavigationController.NavigationDetails details, ProgressBar progressBar) { if (!FormEntryConstants.NAV_STATE_NEXT.equals(nextButton.getTag())) { nextButton.setTag(FormEntryConstants.NAV_STATE_NEXT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { finishButton.setVisibility(View.GONE); } } progressBar.setProgressDrawable(context.getResources().getDrawable(R.drawable.progressbar_modern)); progressBar.setProgress(details.completedQuestions); }
Example 7
Source File: NotifyUtils.java From Conquer with Apache License 2.0 | 5 votes |
public static void pauseAudio(ImageButton ib_play) { // 暂停播放,保存播放进度 if (player != null && player.isPlaying()) { curPosition = player.getCurrentPosition(); player.pause(); if (timer_play != null) { timer_play.cancel(); timer_play = null; } if (ib_play != null) { ib_play.setImageResource(R.drawable.play_audio); ib_play.setTag("play"); } } }
Example 8
Source File: InfoActivity.java From Bluefruit_LE_Connect_Android with MIT License | 5 votes |
@NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { ElementPath elementPath = getItem(position); if (convertView == null) { convertView = mActivity.getLayoutInflater().inflate(R.layout.layout_info_item_descriptor, parent, false); } // Tag convertView.setTag(elementPath); // Name TextView nameTextView = (TextView) convertView.findViewById(R.id.nameTextView); nameTextView.setText(elementPath.isShowingName ? elementPath.name : elementPath.uuid); // Value TextView valueTextView = (TextView) convertView.findViewById(R.id.valueTextView); byte[] value = mValuesMap.get(elementPath.getKey()); String valueString = getValueFormattedInGraphicCharacters(value, elementPath); valueTextView.setText(valueString); valueTextView.setVisibility(valueString == null ? View.GONE : View.VISIBLE); // Update button ImageButton updateButton = (ImageButton) convertView.findViewById(R.id.updateButton); updateButton.setTag(elementPath); return convertView; }
Example 9
Source File: MyHistoryAdapter.java From Conquer with Apache License 2.0 | 5 votes |
/** * 播放声音的 * */ private void initAudio(final View view, final String audioUrl) { final ImageButton ib_play = (ImageButton) view.findViewById(R.id.ib_play); // 删除隐藏该布局 view.findViewById(R.id.iv_del).setVisibility(View.GONE); // 播放按钮 ib_play.setImageResource(R.drawable.play_audio); ib_play.setTag("play"); ib_play.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { aUtils.play(context, view, audioUrl); } }); }
Example 10
Source File: AbstractInfoFragment.java From Kore with Apache License 2.0 | 5 votes |
private void setupToggleButton(final ImageButton button, final View.OnClickListener listener) { button.setVisibility(View.VISIBLE); button.setTag(false); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { listener.onClick(view); // Boldly invert the state. We depend on the observer to correct the state // if Kodi or other service didn't honour our request setToggleButtonState(button, ! (boolean) button.getTag()); } }); }
Example 11
Source File: People.java From android-popup-info with Apache License 2.0 | 5 votes |
public static View inflatePersonView(Context context, ViewGroup parent, Person person) { LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ImageButton personView = (ImageButton)inflater.inflate(R.layout.button_person, parent, false); personView.setImageDrawable(context.getResources().getDrawable(person.getIcon())); personView.setContentDescription(person.getName()); personView.setOnClickListener(mClickPersonView); personView.setTag(person); return personView; }
Example 12
Source File: AbstractInfoFragment.java From Kore with Apache License 2.0 | 4 votes |
private void setToggleButtonState(ImageButton button, boolean state) { UIUtils.highlightImageView(getActivity(), button, state); button.setTag(state); }
Example 13
Source File: AnagramFragment.java From Anagram-Solver with MIT License | 4 votes |
/** * Gets the installed dictionaries and adds ImageButtons dynamically in LinearLayout. * <p/> * It also initialize them with onClick events. */ private void initLanguages(String[] installedDicts) { for (String lang : installedDicts) { ImageButton languageImageButton = new ImageButton(getActivity()); languageImageButton.setBackgroundColor(Color.TRANSPARENT); languageImageButton.setImageDrawable(getActivity().getResources().getDrawable(Dictionary.getDrawableId(lang))); //set layout parameters LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); //weight set to 1 to have same distance between languages.. params.weight = 1; languageImageButton.setLayoutParams(params); //set language to Tag languageImageButton.setTag(lang); languageImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(view != currentDict) { //send singal to change the parser String dictionarySelected = (String) view.getTag(); anagramTextWatcher.dictionaryChange(dictionarySelected); //make previous selected language semi transparent ViewUtils.setAlpha(currentDict, ViewUtils.DEFAULT_SEMI_ALPHA, 0); //set clicked language as current dictionary and set to full alpha currentDict = view; ViewUtils.setAlpha(view, ViewUtils.DEFAULT_FULL_ALPHA, 0); } } }); if (currentDict == null) { currentDict = languageImageButton; ViewUtils.setAlpha(languageImageButton, ViewUtils.DEFAULT_FULL_ALPHA, 0); } else { ViewUtils.setAlpha(languageImageButton, ViewUtils.DEFAULT_SEMI_ALPHA, 0); } //add to languages section languages.addView(languageImageButton); } }
Example 14
Source File: CameraAdapter.java From RPiCameraViewer with MIT License | 4 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { // get the view type int type = getItemViewType(position); // inflate the view if necessary final Context context = parent.getContext(); if (convertView == null) { LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate((type == VIEW_CAMERA) ? R.layout.row_camera : R.layout.row_message, null); } if (type == VIEW_CAMERA) { // get the camera for this row Camera camera = getItem(position); if (camera != null) { // get the views convertView.setTag(camera); TextView name = convertView.findViewById(R.id.camera_name); TextView address = convertView.findViewById(R.id.camera_address); ImageButton edit = convertView.findViewById(R.id.camera_edit); edit.setTag(camera); edit.setOnClickListener(editButtonOnClickListener); // set the views name.setText(camera.name); String addr = camera.address + ":" + camera.port; if (showNetwork && Utils.isIpAddress(camera.address)) { addr = camera.network + ":" + addr; } address.setText(addr); } } else { TextView msg = convertView.findViewById(R.id.message_text); msg.setText(R.string.no_cameras); Button scan = convertView.findViewById(R.id.message_scan); scan.setOnClickListener(scanButtonOnClickListener); } // return the view return convertView; }
Example 15
Source File: EmojiPalettesView.java From Indic-Keyboard with Apache License 2.0 | 4 votes |
@Override protected void onFinishInflate() { mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost); mTabHost.setup(); for (final EmojiCategory.CategoryProperties properties : mEmojiCategory.getShownCategories()) { addTab(mTabHost, properties.mCategoryId); } mTabHost.setOnTabChangedListener(this); final TabWidget tabWidget = mTabHost.getTabWidget(); tabWidget.setStripEnabled(mCategoryIndicatorEnabled); if (mCategoryIndicatorEnabled) { // On TabWidget's strip, what looks like an indicator is actually a background. // And what looks like a background are actually left and right drawables. tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId); tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId); tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId); } mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this); mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager); mEmojiPager.setAdapter(mEmojiPalettesAdapter); mEmojiPager.setOnPageChangeListener(this); mEmojiPager.setOffscreenPageLimit(0); mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE); mEmojiLayoutParams.setPagerProperties(mEmojiPager); mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view); mEmojiCategoryPageIndicatorView.setColors( mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground); mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView); setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */); final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar); mEmojiLayoutParams.setActionBarProperties(actionBar); // deleteKey depends only on OnTouchListener. mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete); mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId); mDeleteKey.setTag(Constants.CODE_DELETE); mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener); // {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on // {@link View.OnClickListener} as well as {@link View.OnTouchListener}. // {@link View.OnTouchListener} is used as the trigger of key-press, while // {@link View.OnClickListener} is used as the trigger of key-release which does not occur // if the event is canceled by moving off the finger from the view. // The text on alphabet keys are set at // {@link #startEmojiPalettes(String,int,float,Typeface)}. mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left); mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyLeft.setOnTouchListener(this); mAlphabetKeyLeft.setOnClickListener(this); mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right); mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyRight.setOnTouchListener(this); mAlphabetKeyRight.setOnClickListener(this); mSpacebar = findViewById(R.id.emoji_keyboard_space); mSpacebar.setBackgroundResource(mSpacebarBackgroundId); mSpacebar.setTag(Constants.CODE_SPACE); mSpacebar.setOnTouchListener(this); mSpacebar.setOnClickListener(this); mEmojiLayoutParams.setKeyProperties(mSpacebar); mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); }
Example 16
Source File: AppDetailsActivity.java From product-emm with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_app_details); context = AppDetailsActivity.this.getApplicationContext(); applicationManager = new ApplicationManager(context); if (getIntent().getSerializableExtra(context.getResources(). getString(R.string.intent_extra_application)) != null) { application = (Application) getIntent().getSerializableExtra(context.getResources(). getString(R.string.intent_extra_application)); } ImageView imgBanner = (ImageView)findViewById(R.id.imgBanner); ImageView imgAppIcon = (ImageView)findViewById(R.id.imgAppIcon); TextView txtAppName = (TextView)findViewById(R.id.txtAppName); TextView txtProvider = (TextView)findViewById(R.id.txtProvider); TextView txtDescription = (TextView)findViewById(R.id.txtDescription); TextView txtAppHeading = (TextView)findViewById(R.id.txtAppHeading); ImageView imgScreenshot1 = (ImageView)findViewById(R.id.imgScreenshot1); ImageView imgScreenshot2 = (ImageView)findViewById(R.id.imgScreenshot2); ImageView imgScreenshot3 = (ImageView)findViewById(R.id.imgScreenshot3); ImageButton btnBack = (ImageButton)findViewById(R.id.btnBack); btnBack.setTag(TAG_BTN_BACK); btnBack.setOnClickListener(onClickListener); Button btnInstall = (Button)findViewById(R.id.btnInstall); btnInstall.setTag(TAG_BTN_INSTALL); btnInstall.setOnClickListener(onClickListener); TextView btnReadMore = (TextView)findViewById(R.id.btnReadMore); btnReadMore.setTag(TAG_BTN_READ_MORE); btnReadMore.setOnClickListener(onClickListener); if (application != null) { txtAppName.setText(application.getName()); txtDescription.setText(application.getDescription()); txtProvider.setText(application.getCategory()); txtAppHeading.setText(application.getName()); Picasso.with(context).load(application.getBanner()).into(imgBanner); Picasso.with(context).load(application.getIcon()).into(imgAppIcon); if (application.getScreenshots() != null) { if (application.getScreenshots().size() > 0 && application.getScreenshots().get(0) != null) { Picasso.with(context).load(application.getScreenshots().get(0)).into(imgScreenshot1); } if (application.getScreenshots().size() > 1 && application.getScreenshots().get(1) != null) { Picasso.with(context).load(application.getScreenshots().get(1)).into(imgScreenshot2); } if (application.getScreenshots().size() > 2 && application.getScreenshots().get(2) != null) { Picasso.with(context).load(application.getScreenshots().get(2)).into(imgScreenshot3); } } if (applicationManager.isPackageInstalled(application.getPackageName())) { btnInstall.setBackgroundColor(Color.parseColor(Constants.UNINSTALL_BUTTON_COLOR)); btnInstall.setText(context.getResources().getString(R.string.action_uninstall)); btnInstall.setTag(TAG_BTN_UNINSTALL); btnInstall.setOnClickListener(onClickListener); } else { btnInstall.setBackgroundColor(Color.parseColor(Constants.INSTALL_BUTTON_COLOR)); btnInstall.setText(context.getResources().getString(R.string.action_install)); btnInstall.setTag(TAG_BTN_INSTALL); btnInstall.setOnClickListener(onClickListener); } } }
Example 17
Source File: FormNavigationUI.java From commcare-android with Apache License 2.0 | 4 votes |
/** * Update progress bar's max and value, and the various buttons and navigation cues * associated with navigation */ public static void updateNavigationCues(CommCareActivity activity, FormController formController, QuestionsView view) { if (view == null) { return; } updateFloatingLabels(activity, view); FormNavigationController.NavigationDetails details; try { details = FormNavigationController.calculateNavigationStatus(formController, view); } catch (XPathException e) { UserfacingErrorHandling.logErrorAndShowDialog(activity, e, true); return; } ProgressBar progressBar = activity.findViewById(R.id.nav_prog_bar); ImageButton nextButton = activity.findViewById(R.id.nav_btn_next); ImageButton prevButton = activity.findViewById(R.id.nav_btn_prev); ClippingFrame finishButton = activity. findViewById(R.id.nav_btn_finish); if (!details.relevantBeforeCurrentScreen) { prevButton.setImageResource(R.drawable.icon_close_darkwarm); prevButton.setTag(FormEntryConstants.NAV_STATE_QUIT); } else { prevButton.setImageResource(R.drawable.icon_chevron_left_brand); prevButton.setTag(FormEntryConstants.NAV_STATE_BACK); } //Apparently in Android 2.3 setting the drawable resource for the progress bar //causes it to lose it bounds. It's a bit cheaper to keep them around than it //is to invalidate the view, though. Rect bounds = progressBar.getProgressDrawable().getBounds(); //Save the drawable bound Log.i("Questions", "Total questions: " + details.totalQuestions + " | Completed questions: " + details.completedQuestions); progressBar.setMax(details.totalQuestions); if (details.isFormDone()) { setDoneState(nextButton, activity, finishButton, details, progressBar); } else { setMoreQuestionsState(nextButton, activity, finishButton, details, progressBar); } progressBar.getProgressDrawable().setBounds(bounds); //Set the bounds to the saved value }
Example 18
Source File: EmojiPalettesView.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 4 votes |
@Override protected void onFinishInflate() { mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost); mTabHost.setup(); for (final EmojiCategory.CategoryProperties properties : mEmojiCategory.getShownCategories()) { addTab(mTabHost, properties.mCategoryId); } mTabHost.setOnTabChangedListener(this); final TabWidget tabWidget = mTabHost.getTabWidget(); tabWidget.setStripEnabled(mCategoryIndicatorEnabled); if (mCategoryIndicatorEnabled) { // On TabWidget's strip, what looks like an indicator is actually a background. // And what looks like a background are actually left and right drawables. tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId); tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId); tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId); } mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this); mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager); mEmojiPager.setAdapter(mEmojiPalettesAdapter); mEmojiPager.setOnPageChangeListener(this); mEmojiPager.setOffscreenPageLimit(0); mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE); mEmojiLayoutParams.setPagerProperties(mEmojiPager); mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view); mEmojiCategoryPageIndicatorView.setColors( mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground); mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView); setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */); final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar); mEmojiLayoutParams.setActionBarProperties(actionBar); // deleteKey depends only on OnTouchListener. mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete); mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId); mDeleteKey.setTag(Constants.CODE_DELETE); mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener); // {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on // {@link View.OnClickListener} as well as {@link View.OnTouchListener}. // {@link View.OnTouchListener} is used as the trigger of key-press, while // {@link View.OnClickListener} is used as the trigger of key-release which does not occur // if the event is canceled by moving off the finger from the view. // The text on alphabet keys are set at // {@link #startEmojiPalettes(String,int,float,Typeface)}. mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left); mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyLeft.setOnTouchListener(this); mAlphabetKeyLeft.setOnClickListener(this); mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right); mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId); mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI); mAlphabetKeyRight.setOnTouchListener(this); mAlphabetKeyRight.setOnClickListener(this); mSpacebar = findViewById(R.id.emoji_keyboard_space); mSpacebar.setBackgroundResource(mSpacebarBackgroundId); mSpacebar.setTag(Constants.CODE_SPACE); mSpacebar.setOnTouchListener(this); mSpacebar.setOnClickListener(this); mEmojiLayoutParams.setKeyProperties(mSpacebar); mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon); }
Example 19
Source File: InfoActivity.java From Bluefruit_LE_Connect_Android with MIT License | 4 votes |
@Override public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { ElementPath elementPath = (ElementPath) getChild(groupPosition, childPosition); if (convertView == null) { convertView = mActivity.getLayoutInflater().inflate(R.layout.layout_info_item_characteristic, parent, false); } BluetoothGattService service = mBleManager.getGattService(elementPath.serviceUUID, elementPath.serviceInstance); boolean isReadable = elementPath.characteristicUUID != null && mBleManager.isCharacteristicReadable(service, elementPath.characteristicUUID); // Tag convertView.setTag(elementPath); // Name TextView nameTextView = (TextView) convertView.findViewById(R.id.nameTextView); nameTextView.setText(elementPath.isShowingName ? elementPath.name : elementPath.uuid); // Value TextView valueTextView = (TextView) convertView.findViewById(R.id.valueTextView); byte[] value = mValuesMap.get(elementPath.getKey()); String valueString = getValueFormattedInGraphicCharacters(value, elementPath); valueTextView.setText(valueString); valueTextView.setVisibility(valueString == null ? View.GONE : View.VISIBLE); // Update button ImageButton updateButton = (ImageButton) convertView.findViewById(R.id.updateButton); updateButton.setVisibility(isReadable ? View.VISIBLE : View.GONE); updateButton.setTag(elementPath); // Notify button ImageButton notifyButton = (ImageButton) convertView.findViewById(R.id.notifyButton); boolean isNotifiable = elementPath.characteristicUUID != null && elementPath.descriptorUUID == null && mBleManager.isCharacteristicNotifiable(service, elementPath.characteristicUUID); notifyButton.setVisibility(isNotifiable ? View.VISIBLE : View.GONE); notifyButton.setTag(elementPath); // List setup ExpandableHeightListView listView = (ExpandableHeightListView) convertView.findViewById(R.id.descriptorsListView); listView.setExpanded(true); // Descriptors final String key = elementPath.getKey(); List<ElementPath> descriptorNamesList = mDescriptors.get(key); DescriptorAdapter adapter = new DescriptorAdapter(mActivity, R.layout.layout_info_item_descriptor, descriptorNamesList); listView.setAdapter(adapter); return convertView; }
Example 20
Source File: StatusDetailDialogFragment.java From SmileEssence with MIT License | 4 votes |
private View getTitleView(MainActivity activity, Account account, Status status) { View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null); View statusHeader = view.findViewById(R.id.layout_status_header); StatusViewModel statusViewModel = new StatusViewModel(status, account); statusHeader = statusViewModel.getView(activity, activity.getLayoutInflater(), statusHeader); statusHeader.setClickable(false); int background = ((ColorDrawable) statusHeader.getBackground()).getColor(); view.setBackgroundColor(background); ImageView favCountIcon = (ImageView) view.findViewById(R.id.image_status_detail_fav_count); ImageView rtCountIcon = (ImageView) view.findViewById(R.id.image_status_detail_rt_count); TextView favCountText = (TextView) view.findViewById(R.id.textview_status_detail_fav_count); TextView rtCountText = (TextView) view.findViewById(R.id.textview_status_detail_rt_count); int favoriteCount = TwitterUtils.getOriginalStatus(status).getFavoriteCount(); if (favoriteCount == 0) { favCountIcon.setVisibility(View.GONE); favCountText.setVisibility(View.GONE); } else { favCountText.setText(Integer.toString(favoriteCount)); } int retweetCount = TwitterUtils.getOriginalStatus(status).getRetweetCount(); if (retweetCount == 0) { rtCountIcon.setVisibility(View.GONE); rtCountText.setVisibility(View.GONE); } else { rtCountText.setText(Integer.toString(retweetCount)); } ImageButton menu = (ImageButton) view.findViewById(R.id.button_status_detail_menu); ImageButton message = (ImageButton) view.findViewById(R.id.button_status_detail_reply); ImageButton retweet = (ImageButton) view.findViewById(R.id.button_status_detail_retweet); ImageButton favorite = (ImageButton) view.findViewById(R.id.button_status_detail_favorite); ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete); menu.setOnClickListener(this); message.setOnClickListener(this); retweet.setOnClickListener(this); favorite.setOnClickListener(this); delete.setOnClickListener(this); if (isNotRetweetable(account, status)) { retweet.setVisibility(View.GONE); } else if (isRetweetDeletable(account, status)) { retweet.setImageDrawable(getResources().getDrawable(R.drawable.icon_retweet_on)); retweet.setTag(status.getId()); } else { retweet.setTag(-1L); } favorite.setTag(statusViewModel.isFavorited()); if (statusViewModel.isFavorited()) { favorite.setImageDrawable(getResources().getDrawable(R.drawable.icon_favorite_on)); } boolean deletable = isDeletable(account, status); delete.setVisibility(deletable ? View.VISIBLE : View.GONE); LinearLayout commandsLayout = (LinearLayout) view.findViewById(R.id.linearlayout_status_detail_menu); commandsLayout.setClickable(true); ArrayList<Command> commands = getCommands(activity, status, account); Command.filter(commands); for (final Command command : commands) { View commandView = command.getView(activity, activity.getLayoutInflater(), null); commandView.setBackgroundColor(getResources().getColor(R.color.transparent)); commandView.setOnClickListener(new ListItemClickListener(activity, new Runnable() { @Override public void run() { command.execute(); dismiss(); } })); commandsLayout.addView(commandView); } return view; }