List of usage examples for android.widget TextView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.flipzu.flipzu.Recorder.java
@Override public void onCommentsReceived(Hashtable<String, String>[] comments) { debug.logV(TAG, "onCommentsReceived"); final LinearLayout cc = (LinearLayout) findViewById(R.id.comments_container); /* cleanup comments first */ cc.removeAllViews();/*from www .ja v a 2 s. c o m*/ /* get pixel values for various DIPs */ final float scale = getResources().getDisplayMetrics().density; // final int pixel_10 = 10 / (int) (scale + 0.5f); final int pixel_5 = 5 / (int) (scale + 0.5f); // final int pixel_30 = 30 / (int) (scale + 0.5f); final LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); if (comments != null && comments.length > 0) { for (int i = 0; i < comments.length; i++) { LinearLayout cl = new LinearLayout(Recorder.this); cl.setOrientation(LinearLayout.HORIZONTAL); cl.setPadding(0, 0, 0, pixel_5); debug.logD(TAG, "Refresher comment " + comments[i]); /* comment */ TextView comment_tv = new TextView(Recorder.this); comment_tv.setLayoutParams(params); comment_tv.setText(comments[i].get("username") + ": " + comments[i].get("comment"), TextView.BufferType.SPANNABLE); comment_tv.setTextColor(Color.parseColor("#656565")); Spannable comment_span = (Spannable) comment_tv.getText(); comment_span.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, comment_tv.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); comment_span.setSpan(new ForegroundColorSpan(Color.parseColor("#182e5b")), 0, comments[i].get("username").length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); comment_tv.setText(comment_span); cl.addView(comment_tv); cc.addView(cl); } } else { if (mState == recorderState.RECORDING) { String msg = "You're LIVE! Your broadcast can be heard at http://flipzu.com/" + mUser.getUsername(); showFlipzuTipsOffline(cc, params, msg); } else { String msg = "Pick a good and descriptive broadcast title. A great title will attract more listeners!"; showFlipzuTipsOffline(cc, params, msg); msg = "You can disable sharing in Twitter and Facebook by clicking the logo buttons. This is great for testing."; showFlipzuTipsOffline(cc, params, msg); msg = "Press the \"Start Broadcast\" button and let them hear you!"; showFlipzuTipsOffline(cc, params, msg); } } }
From source file:com.azuyo.happybeing.fourmob.timepicker.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.hour_picker_description); mSelectHours = res.getString(R.string.select_hours); mMinutePickerDescription = res.getString(R.string.minute_picker_description); mSelectMinutes = res.getString(R.string.select_minutes); mBlue = res.getColor(R.color.app_blue); mBlack = res.getColor(R.color.numbers_text_color); mWhite = res.getColor(R.color.white); mHourView = (TextView) view.findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space); mMinuteView = (TextView) view.findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); if (Build.VERSION.SDK_INT <= 14) { mAmPmTextView.setTransformationMethod(new TransformationMethod() { private final Locale locale = getResources().getConfiguration().locale; @Override/*w ww.j a va 2 s . c o m*/ public CharSequence getTransformation(CharSequence source, View view) { return source != null ? source.toString().toUpperCase(locale) : null; } @Override public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction, Rect previouslyFocusedRect) { } }); } String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mInitialHourOfDay, mInitialMinute, mIs24HourMode, mVibrate); int currentItemShowing = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } setCurrentItemShowing(currentItemShowing, false, true, true); mTimePicker.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); mTimePicker.tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); mTimePicker.tryVibrate(); } }); mCancelButton = (TextView) view.findViewById(R.id.cancel_button); mDoneButton = (TextView) view.findViewById(R.id.done_button); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); mCancelButton.setOnKeyListener(keyboardListener); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onDoneButtonClick(); } }); mDoneButton.setOnKeyListener(keyboardListener); // Enable or disable the AM/PM view. mAmPmHitspace = view.findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mTimePicker.tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } }); } mAllowAutoAdvance = true; setHour(mInitialHourOfDay, true); setMinute(mInitialMinute); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.time_placeholder); mDeletedKeyFormat = res.getString(R.string.deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<Integer>(); } return view; }
From source file:com.android.datetimepicker.time.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.hour_picker_description); mSelectHours = res.getString(R.string.select_hours); mMinutePickerDescription = res.getString(R.string.minute_picker_description); mSelectMinutes = res.getString(R.string.select_minutes); mSelectedColor = res.getColor(mThemeDark ? R.color.red : R.color.blue); mUnselectedColor = res.getColor(mThemeDark ? R.color.white : R.color.numbers_text_color); mHourView = (TextView) view.findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space); mMinuteView = (TextView) view.findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0];/*from ww w . jav a2s . c o m*/ mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getActivity()); mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute, mIs24HourMode); int currentItemShowing = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } setCurrentItemShowing(currentItemShowing, false, true, true); mTimePicker.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); tryVibrate(); } }); mDoneButton = (TextView) view.findViewById(R.id.done_button); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } }); mDoneButton.setOnKeyListener(keyboardListener); // Enable or disable the AM/PM view. mAmPmHitspace = view.findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } }); } mAllowAutoAdvance = true; setHour(mInitialHourOfDay, true); setMinute(mInitialMinute); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.time_placeholder); mDeletedKeyFormat = res.getString(R.string.deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<Integer>(); } // Set the theme at the end so that the initialize()s above don't counteract the theme. mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. int white = res.getColor(R.color.white); int circleBackground = res.getColor(R.color.circle_background); int line = res.getColor(R.color.line_background); int timeDisplay = res.getColor(R.color.numbers_text_color); ColorStateList doneTextColor = res.getColorStateList(R.color.done_text_color); int doneBackground = R.drawable.done_background_color; int darkGray = res.getColor(R.color.dark_gray); int lightGray = res.getColor(R.color.light_gray); int darkLine = res.getColor(R.color.line_dark); ColorStateList darkDoneTextColor = res.getColorStateList(R.color.done_text_color_dark); int darkDoneBackground = R.drawable.done_background_color_dark; // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white); ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay); view.findViewById(R.id.line).setBackgroundColor(mThemeDark ? darkLine : line); mDoneButton.setTextColor(mThemeDark ? darkDoneTextColor : doneTextColor); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); mDoneButton.setBackgroundResource(mThemeDark ? darkDoneBackground : doneBackground); return view; }
From source file:com.example.de.taomi2.mediachooser.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); }/*w ww . j ava 2 s . c om*/ if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }
From source file:com.github.devnied.emvnfccard.view.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); mTabStrip.removeAllViews();//from ww w . j ava2 s . co m if (adapter.getCount() > 1) { for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextColor(Color.WHITE); tabView.setOnClickListener(tabClickListener); tabTitleView.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1 / (float) adapter.getCount())); mTabStrip.addView(tabView); } } }
From source file:it.ielettronica.TVS.MyListAdapterExt.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { //If there's no recycled view, inflate one and tag each of the views //you'll want to modify later //Log.d("Inside", "GetView"); plv = null;/*from w w w .j a va 2 s . co m*/ if (convertView == null) { convertView = mInflater.inflate(R.layout.row_site_remote, parent, false); plv = new PlaylistValues(); plv.nameTxt = (TextView) convertView.findViewById(R.id.nameTxt); plv.aboutTxt = (TextView) convertView.findViewById(R.id.aboutTxt); plv.iconImg = (ImageView) convertView.findViewById(R.id.iconImg); plv.btnPlayLocal = (Button) convertView.findViewById(R.id.btnPlayLocal); plv.indicator = (ProgressBar) convertView.findViewById(R.id.progress); plv.btnAddLocal = (Button) convertView.findViewById(R.id.btnAddLocal); plv.imageState = (ImageView) convertView.findViewById(R.id.imgState); plv.btnEditDel = (Button) convertView.findViewById(R.id.btnEditDel); //This assumes layout/row_left.xml includes a TextView with an id of "textview" convertView.setTag(plv); } else { plv = (PlaylistValues) convertView.getTag(); } //Initially we want the progress indicator visible, and the image invisible plv.indicator.setVisibility(View.VISIBLE); plv.iconImg.setVisibility(View.INVISIBLE); if (MainActivity.isAmministrator()) { plv.btnEditDel.setVisibility(View.VISIBLE); } else { plv.btnEditDel.setVisibility(View.INVISIBLE); } //Retrieve the tagged view, get the item for that position, and //update the text ImageLoadingListener listener = new ImageLoadingListener() { @Override public void onLoadingStarted(String arg0, View arg1) { // TODO Auto-generated method stub plv.indicator.setVisibility(View.INVISIBLE); plv.iconImg.setVisibility(View.VISIBLE); } @Override public void onLoadingCancelled(String arg0, View arg1) { // TODO Auto-generated method stub } @Override public void onLoadingComplete(String arg0, View arg1, Bitmap arg2) { //plv.indicator.setVisibility(View.INVISIBLE); //plv.iconImg.setVisibility(View.VISIBLE); } @Override public void onLoadingFailed(String arg0, View arg1, FailReason arg2) { // TODO Auto-generated method stub } }; stk = mItems.get(position); plv.nameTxt.setText(stk.getName()); plv.aboutTxt.setText(stk.getAbout()); String uri = "@drawable/myresource"; // where myresource.png is the file // extension removed from the String if (MainActivity.isAmministrator() == Boolean.TRUE) { Drawable res; if (stk.getAccepted() == 1) { res = ContextCompat.getDrawable(MainActivity.getAppContext(), R.drawable.good); } else { res = ContextCompat.getDrawable(MainActivity.getAppContext(), R.drawable.warning); } plv.imageState.setImageDrawable(res); } imageLoader.displayImage(stk.getImgUrl(), plv.iconImg, options, listener); plv.btnEditDel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final StackSite stkloc = mItems.get(position); MainActivity.posRemoteListBeforeExecuted = sitesMusic.getFirstVisiblePosition(); Intent intent = new Intent(MainActivity.getAppContext(), ModChannel.class); intent.putExtra("TitleChannel", stkloc.getName()); intent.putExtra("DescrChannel", stkloc.getAbout()); intent.putExtra("IconChannel", stkloc.getImgUrl()); intent.putExtra("isAccepted", stkloc.getAccepted()); intent.putExtra("NameGroup", GroupVSeletced.getGroupName()); intent.putExtra("LevelGroup", GroupVSeletced.getGroupLevel()); intent.putExtra("TypeGroup", GroupVSeletced.getGroupType()); intent.putExtra("GroupLevel", GroupVSeletced.getGroupLevel()); tabFromDB.fa.startActivity(intent); } }); plv.btnPlayLocal.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // final Intent intent = new Intent(v.getContext(), MediaPlayerDemo_Video.class); final StackSite stkloc = mItems.get(position); MainActivity.posRemoteListBeforeExecuted = sitesMusic.getFirstVisiblePosition(); GroupType = GroupVSeletced.getGroupType(); RemoteCommunications rm = new RemoteCommunications(); List<StackLink> Links = new ArrayList<StackLink>(); rm.getLinks(Links, stkloc.getName(), new GetLinkCallback() { @Override public void done(List<StackLink> returnedLinks) { List<StackLink> Links = returnedLinks; if (Links.size() == 1) { MainActivity.posLocalListBeforeExecuted = tabFromDB.sitesMusic .getFirstVisiblePosition(); if (MainActivity.isAmministrator()) { Intent intent = new Intent(MainActivity.getAppContext(), LinksLists.class); intent.putExtra("VideoStreamName", stkloc.getName()); intent.putExtra("GroupType", GroupType); tabFromDB.fa.startActivity(intent); } else { String linkVal = Links.get(0).getLinkValue(); //Uri myUri = Uri.parse(linkVal); if (GroupType == 0) { Intent mpdIntent = new Intent(tabLocal.Fa.getContext(), PlayerActivity.class) .setData(Uri.parse(linkVal)) .putExtra(PlayerActivity.CONTENT_ID_EXTRA, "") .putExtra(PlayerActivity.CONTENT_TYPE_EXTRA, PlayerActivity.TYPE_HLS) .putExtra(PlayerActivity.PROVIDER_EXTRA, ""); tabFromDB.fa.getContext().startActivity(mpdIntent); } else if (GroupType == 1) { // Intent intent2 = new Intent(tabLocal.Fa.getContext(), MediaPlayerDemo_VideoView.class); // intent2.putExtra("pathValue", linkVal); // tabFromDB.fa.getContext().startActivity(intent2); } else { // intent.putExtra("media", 5); // intent.putExtra("pathValue", linkVal); // // try { // tabFromDB.fa.startActivity(intent); // } catch (Exception ex) { // Toast.makeText(cloc, ex.toString(), // Toast.LENGTH_SHORT).show(); // } } Toast.makeText(cloc, "Play: " + stkloc.getName(), Toast.LENGTH_SHORT).show(); } } else if (Links.size() == 0) { Toast.makeText(cloc, "the channel: '" + stkloc.getName() + "' doesn't have any link associated", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(MainActivity.getAppContext(), LinksLists.class); intent.putExtra("VideoStreamName", stkloc.getName()); tabFromDB.fa.startActivity(intent); } } }); } }); plv.btnAddLocal.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { stkloc = mItems.get(position); RemoteCommunications rm = new RemoteCommunications(); List<StackLink> Links = new ArrayList<StackLink>(); rm.getLinks(Links, stkloc.getName(), new GetLinkCallback() { @Override public void done(List<StackLink> returnedLinks) { AlertDialog.Builder alertDialog; try { alertDialog = new AlertDialog.Builder(tabFromDB.fa.getContext()); } catch (Exception ex) { alertDialog = new AlertDialog.Builder(MainActivity.getAppContext()); } retLinks = returnedLinks; LinearLayout layout = new LinearLayout(MainActivity.getAppContext()); layout.setOrientation(LinearLayout.VERTICAL); if (returnedLinks.size() > 1) { LinearLayout rlayoutLink = new LinearLayout(MainActivity.getAppContext()); rlayoutLink.setOrientation(LinearLayout.HORIZONTAL); final TextView textView = new TextView(MainActivity.getAppContext()); textView.setText("Links: "); textView.setGravity(Gravity.RIGHT); textView.setLayoutParams( new FrameLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT)); rlayoutLink.addView(textView); listLinks = new Spinner(MainActivity.getAppContext()); List<String> retLinksString = new ArrayList<String>(); for (int i = 0; i < returnedLinks.size(); i++) { retLinksString.add(returnedLinks.get(i).getLinkTxt()); } listLinks.setAdapter(new MyCustomAdapter(MainActivity.getAppContext(), R.layout.rowspinnertake, retLinksString, returnedLinks)); //ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.getAppContext(), android.R.layout.simple_spinner_item, retLinksString); //adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //listLinks.setAdapter(adapter); listLinks.setLayoutParams( new FrameLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); rlayoutLink.addView(listLinks); layout.addView(rlayoutLink); } final Button btnAddToTheEnd = new Button(MainActivity.getAppContext()); btnAddToTheEnd.setText("Add"); btnAddToTheEnd.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { StackSite stkloc = mItems.get(position); if (listLinks != null) { posSpinnerLink = listLinks.getSelectedItemPosition(); } else { posSpinnerLink = 0; } if (retLinks.size() == 0) { Toast.makeText(cloc, "the channel: '" + stkloc.getName() + "' doesn't have any link associated", Toast.LENGTH_SHORT).show(); } else { String url; if (retLinks.size() == 1) { url = retLinks.get(0).getLinkValue(); } else { url = retLinks.get(posSpinnerLink).getLinkValue(); } stkloc.setLink(url); stkloc.setTypeStream(GroupVSeletced.getGroupType()); stkloc.setStaticName(stkloc.getName()); String nameStation = stkloc.getName(); stkloc.setOrigin(0); boolean isAdded = dbHandler.addSite(stkloc); if (isAdded) { Toast.makeText(MainActivity.getAppContext(), nameStation + " is added in Local Playlist", Toast.LENGTH_SHORT) .show(); } List<StackSite> itemsLocal; itemsLocal = dbHandler.getStackSites(); if (itemsLocal.size() == 0) { tabLocal.editEmptyLocalList.setVisibility(View.VISIBLE); } else { tabLocal.editEmptyLocalList.setVisibility(View.INVISIBLE); } tabLocal.sitesLocal.setCheeseList(itemsLocal); tabLocal.sitesLocal.setChoiceMode(ListView.CHOICE_MODE_SINGLE); StableArrayAdapter adapterLocal = new StableArrayAdapter( tabLocal.Fa.getContext(), R.layout.row_site_local, itemsLocal); tabLocal.sitesLocal.setAdapter(adapterLocal); OptionDialog.dismiss(); } } }); btnAddToTheEnd.setLayoutParams( new FrameLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT)); layout.addView(btnAddToTheEnd); final Button btnAddAfter = new Button(MainActivity.getAppContext()); final Spinner listChannelAlreadyAdded = new Spinner(MainActivity.getAppContext()); List<String> ListNameChannel; ListNameChannel = dbHandler.getNamesFromStackSites(); ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(MainActivity.getAppContext(), android.R.layout.simple_spinner_item, ListNameChannel); adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); listChannelAlreadyAdded.setAdapter(adapter2); posSpinner = listChannelAlreadyAdded.getSelectedItemPosition(); if (posSpinner != -1) { LinearLayout rlayout = new LinearLayout(MainActivity.getAppContext()); rlayout.setOrientation(LinearLayout.HORIZONTAL); btnAddAfter.setText("Add Before"); btnAddAfter.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (listLinks != null) { posSpinnerLink = listLinks.getSelectedItemPosition(); } else { posSpinnerLink = 0; } StackSite stkloc = mItems.get(position); if (retLinks.size() == 0) { Toast.makeText(cloc, "the channel: '" + stkloc.getName() + "' doesn't have any link associated", Toast.LENGTH_SHORT).show(); } else { String url; if (retLinks.size() == 1) { url = retLinks.get(0).getLinkValue(); } else { url = retLinks.get(posSpinnerLink).getLinkValue(); } stkloc.setLink(url); stkloc.setOrigin(0); stkloc.setTypeStream(GroupVSeletced.getGroupType()); String nameStation = stkloc.getName(); posSpinner = listChannelAlreadyAdded.getSelectedItemPosition(); boolean isAdded = dbHandler.addSiteBefore(stkloc, posSpinner); if (isAdded) { Toast.makeText(MainActivity.getAppContext(), nameStation + " is added in Local Playlist", Toast.LENGTH_SHORT) .show(); } List<StackSite> itemsLocal; itemsLocal = dbHandler.getStackSites(); tabLocal.sitesLocal.setCheeseList(itemsLocal); tabLocal.sitesLocal.setChoiceMode(ListView.CHOICE_MODE_SINGLE); StableArrayAdapter adapterLocal = new StableArrayAdapter( tabLocal.Fa.getContext(), R.layout.row_site_local, itemsLocal); tabLocal.sitesLocal.setAdapter(adapterLocal); OptionDialog.dismiss(); } } }); btnAddAfter.setLayoutParams( new FrameLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT)); rlayout.addView(btnAddAfter); listChannelAlreadyAdded.setLayoutParams( new FrameLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); rlayout.addView(listChannelAlreadyAdded); layout.addView(rlayout); } final Button btnCancel = new Button(MainActivity.getAppContext()); btnCancel.setText("Cancel"); btnCancel.setLayoutParams( new FrameLayout.LayoutParams(400, LinearLayout.LayoutParams.WRAP_CONTENT)); btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { OptionDialog.dismiss(); } }); layout.addView(btnCancel); alertDialog.setView(layout); // uncomment this line alertDialog.setTitle("Take the Channel"); OptionDialog = alertDialog.create(); OptionDialog.show(); } }); } }); return convertView; }
From source file:com.dazone.crewchat.libGallery.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(this); headerBarCamera.setOnClickListener(this); headerBarDone.setOnClickListener(this); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); }// w w w .j av a 2 s. c om if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } mTabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE); for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(Utils.convertDipToPixels(this, 10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = Utils.convertDipToPixels(this, 40); params.width = Utils.convertDipToPixels(this, 40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15)); }
From source file:com.guerinet.materialtabs.TabLayout.java
/** * Creates a default view to be used for tabs. This is called if a custom tab view is not set * via {@link #setCustomTabView(int, int)}. * * @return The default view to use/*from ww w . j av a 2s . c o m*/ */ protected TextView createDefaultTabView() { TextView textView = new TextView(getContext()); prepareTextView(textView); textView.setGravity(Gravity.CENTER); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); //Set the text color if there is one if (this.mDefaultTextColorId != null) { textView.setTextColor(getResources().getColor(mDefaultTextColorId)); } textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setBackgroundResource(getTabBackground()); //Padding int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:info.tellmetime.TellmetimeActivity.java
private void resizeClock() { final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock); // Set width of #mClock layout to the screen's shorter edge size, so clock is not // expanded in landscape mode, but has rather somewhat a square shape. RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.width = mShorterEdge;/*from www . ja v a 2 s. c om*/ mClock.setLayoutParams(lp); final float mItemSize = mShorterEdge / mClock.getChildCount(); final int mRowMargin = (int) -(mItemSize / 2.2); // Scale text size according to shorter edge and set spacing between rows. for (int i = 0; i < mClock.getChildCount(); i++) { LinearLayout row = (LinearLayout) mClock.getChildAt(i); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams(); params.bottomMargin = mRowMargin; row.setLayoutParams(params); for (int j = 0; j < row.getChildCount(); j++) ((TextView) row.getChildAt(j)).setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemSize); } LinearLayout lastRow = (LinearLayout) mClock.getChildAt(mClock.getChildCount() - 1); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) lastRow.getLayoutParams(); params.bottomMargin = 0; lastRow.setLayoutParams(params); TextView twenty = (TextView) findViewById(R.id.twenty); params = (LinearLayout.LayoutParams) twenty.getLayoutParams(); params.leftMargin = 0; twenty.setLayoutParams(params); // Inflates minutes indicators and attaches them to main view. FrameLayout minutesLayout = (FrameLayout) findViewById(R.id.minutes_indicators); minutesLayout.removeAllViews(); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final boolean isLandscape = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; inflater.inflate(isLandscape ? R.layout.minutes_land : R.layout.minutes_portrait, minutesLayout); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : FrameLayout.LayoutParams.WRAP_CONTENT); if (!isLandscape) { layoutParams.addRule(RelativeLayout.BELOW, R.id.clock); layoutParams.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); } minutesLayout.setLayoutParams(layoutParams); ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) ((TextView) minutesDots.getChildAt(i)).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); }
From source file:com.nicolls.ablum.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); pathList = getIntent().getStringArrayListExtra("pathList"); if (pathList == null) { pathList = new ArrayList<>(); }//from w w w . java2 s. co m // Toast.makeText(this,pathList.size()+"-@@@--",Toast.LENGTH_SHORT).show(); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); headerBarCamera.setVisibility(View.GONE); if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); bundle.putStringArrayList("pathList", pathList); // Toast.makeText(this,pathList.size()+"!!!!",Toast.LENGTH_SHORT).show(); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putStringArrayList("pathList", pathList); // Toast.makeText(this,pathList.size()+"!!!",Toast.LENGTH_SHORT).show(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }