List of usage examples for android.view ViewGroup setContentDescription
@RemotableViewMethod public void setContentDescription(CharSequence contentDescription)
From source file:com.cw.litenote.note.Note_adapter.java
@SuppressLint("SetJavaScriptEnabled") @Override/* w w w. j a v a2 s. co m*/ public Object instantiateItem(ViewGroup container, final int position) { System.out.println("Note_adapter / instantiateItem / position = " + position); // Inflate the layout containing // 1. picture group: image,video, thumb nail, control buttons // 2. text group: title, body, time View pagerView = inflater.inflate(R.layout.note_view_adapter, container, false); int style = Note.getStyle(); pagerView.setBackgroundColor(ColorSet.mBG_ColorArray[style]); // Picture group ViewGroup pictureGroup = (ViewGroup) pagerView.findViewById(R.id.pictureContent); String tagPictureStr = "current" + position + "pictureView"; pictureGroup.setTag(tagPictureStr); // image view TouchImageView imageView = ((TouchImageView) pagerView.findViewById(R.id.image_view)); String tagImageStr = "current" + position + "imageView"; imageView.setTag(tagImageStr); // video view VideoViewCustom videoView = ((VideoViewCustom) pagerView.findViewById(R.id.video_view)); String tagVideoStr = "current" + position + "videoView"; videoView.setTag(tagVideoStr); ProgressBar spinner = (ProgressBar) pagerView.findViewById(R.id.loading); // link web view CustomWebView linkWebView = ((CustomWebView) pagerView.findViewById(R.id.link_web_view)); String tagStr = "current" + position + "linkWebView"; linkWebView.setTag(tagStr); // line view View line_view = pagerView.findViewById(R.id.line_view); // text group ViewGroup textGroup = (ViewGroup) pagerView.findViewById(R.id.textGroup); // Set tag for text web view CustomWebView textWebView = ((CustomWebView) textGroup.findViewById(R.id.textBody)); // set accessibility textGroup.setContentDescription(act.getResources().getString(R.string.note_text)); textWebView.getRootView().setContentDescription(act.getResources().getString(R.string.note_text)); tagStr = "current" + position + "textWebView"; textWebView.setTag(tagStr); // set text web view setWebView(textWebView, spinner, CustomWebView.TEXT_VIEW); String linkUri = db_page.getNoteLinkUri(position, true); String strTitle = db_page.getNoteTitle(position, true); String strBody = db_page.getNoteBody(position, true); // View mode // picture only if (Note.isPictureMode()) { System.out.println("Note_adapter / _instantiateItem / isPictureMode "); pictureGroup.setVisibility(View.VISIBLE); showPictureView(position, imageView, videoView, linkWebView, spinner); line_view.setVisibility(View.GONE); textGroup.setVisibility(View.GONE); } // text only else if (Note.isTextMode()) { System.out.println("Note_adapter / _instantiateItem / isTextMode "); pictureGroup.setVisibility(View.GONE); line_view.setVisibility(View.VISIBLE); textGroup.setVisibility(View.VISIBLE); if (Util.isYouTubeLink(linkUri) || !Util.isEmptyString(strTitle) || !Util.isEmptyString(strBody) || linkUri.startsWith("http")) { showTextWebView(position, textWebView); } } // picture and text else if (Note.isViewAllMode()) { System.out.println("Note_adapter / _instantiateItem / isViewAllMode "); // picture pictureGroup.setVisibility(View.VISIBLE); showPictureView(position, imageView, videoView, linkWebView, spinner); line_view.setVisibility(View.VISIBLE); textGroup.setVisibility(View.VISIBLE); // text if (!Util.isEmptyString(strTitle) || !Util.isEmptyString(strBody) || Util.isYouTubeLink(linkUri) || linkUri.startsWith("http")) { showTextWebView(position, textWebView); } else { textGroup.setVisibility(View.GONE); } } // footer of note view TextView footerText = (TextView) pagerView.findViewById(R.id.note_view_footer); if (!Note.isPictureMode()) { footerText.setVisibility(View.VISIBLE); footerText.setText(String.valueOf(position + 1) + "/" + pager.getAdapter().getCount()); footerText.setTextColor(ColorSet.mText_ColorArray[Note.mStyle]); footerText.setBackgroundColor(ColorSet.mBG_ColorArray[Note.mStyle]); } else footerText.setVisibility(View.GONE); container.addView(pagerView, 0); return pagerView; }
From source file:com.cairoconfessions.MainActivity.java
public View addConfession(String confess, String desc) { final ViewGroup confession = (ViewGroup) LayoutInflater.from(this) .inflate(R.layout.confession_list_item_example, null); final TextView newConfess = (TextView) confession.findViewById(R.id.text_main); newConfess.setText(confess);/*from w ww . j av a2 s . c o m*/ final float scale = getResources().getDisplayMetrics().density; if (!desc.equals("")) { confession.setContentDescription(desc); if (desc.equals("Love")) newConfess.setBackgroundResource(R.color.love); if (desc.equals("Pain")) newConfess.setBackgroundResource(R.color.pain); if (desc.equals("Guilt")) newConfess.setBackgroundResource(R.color.guilt); if (desc.equals("Fantasy")) newConfess.setBackgroundResource(R.color.fantasy); if (desc.equals("Dream")) newConfess.setBackgroundResource(R.color.dream); } else { switch ((new Random().nextInt(5)) % 5) { case 0: newConfess.setBackgroundResource(R.color.love); ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh"); confession.setContentDescription("Love"); break; case 1: newConfess.setBackgroundResource(R.color.pain); ((TextView) confession.findViewById(R.id.confess_loc)).setText("Cairo"); confession.setContentDescription("Pain"); break; case 2: newConfess.setBackgroundResource(R.color.guilt); ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York"); confession.setContentDescription("Guilt"); break; case 3: newConfess.setBackgroundResource(R.color.fantasy); ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York"); confession.setContentDescription("Fantasy"); break; case 4: newConfess.setBackgroundResource(R.color.dream); ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh"); confession.setContentDescription("Dream"); break; } } switch ((new Random().nextInt(3)) % 3) { case 0: ((TextView) confession.findViewById(R.id.confess_loc)).setText("Riyadh"); break; case 1: ((TextView) confession.findViewById(R.id.confess_loc)).setText("Cairo"); break; case 2: ((TextView) confession.findViewById(R.id.confess_loc)).setText("New York"); break; } Animation fadeIn = new AlphaAnimation(0, 1); fadeIn.setDuration(1000); confession.setAnimation(fadeIn); confession.getChildAt(0).setPadding((int) (scale * 1.5 + 0.5f), (int) (scale * 1.5 + 0.5f), (int) (scale * 1.5 + 0.5f), (int) (scale * 1.5 + 0.5f)); confession.getChildAt(0).setBackgroundResource(R.drawable.border); mPager.setCurrentItem(1); if (!desc.equals("")) { ((ScrollView) findViewById(R.id.feed)).fullScroll(ScrollView.FOCUS_UP); ((LinearLayout) findViewById(R.id.confession_list)).addView(confession, 0); } else { new Timer().schedule(new TimerTask() { @Override public void run() { ((ScrollView) findViewById(R.id.feed)).fullScroll(ScrollView.FOCUS_UP); ((LinearLayout) findViewById(R.id.confession_list)).post(new Runnable() { public void run() { ((LinearLayout) findViewById(R.id.confession_list)).addView(confession, 0); } }); } }, 1000); } return confession; }