List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java
/** * ??tab.//from w ww . j a v a 2s . c o m * * @param tabTexts the tab texts * @param fragments the fragments */ public void addItemViews(List<String> tabTexts, List<Fragment> fragments) { tabItemTextList.addAll(tabTexts); pagerItemList.addAll(fragments); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } //? mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }
From source file:ar.com.xpasta.Controls.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from www. ja va2 s . c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.brodev.socialapp.view.PhotoGridActivity.java
/** Called when the activity is first created. */ @Override//from w w w. j a v a 2 s.c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ptr_grid); album_id = null; album_user_id = null; countImage = 1; page_id = null; module_id = null; group_id = null; page = 1; mPullRefreshGridView = (PullToRefreshGridView) findViewById(R.id.pull_refresh_grid); mGridView = mPullRefreshGridView.getRefreshableView(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); phraseManager = new PhraseManager(getApplicationContext()); loading = (ProgressBar) findViewById(R.id.content_loading); Bundle bundle = getIntent().getExtras(); if (bundle != null) { if (this.getIntent().hasExtra("album_name")) { if (this.getIntent().hasExtra("total_photo")) { getSupportActionBar() .setTitle(bundle.getString("album_name") + "(" + bundle.getString("total_photo") + ")"); } else { getSupportActionBar().setTitle(bundle.getString("album_name")); } } if (this.getIntent().hasExtra("user_id")) { user_id = bundle.getString("user_id"); new ShowGridPhoto().execute(user_id, null); } else if (this.getIntent().hasExtra("album_user_id")) { album_user_id = bundle.getString("album_user_id"); album_id = bundle.getString("album_id"); new ShowGridPhoto().execute(album_user_id, album_id); } else if (this.getIntent().hasExtra("page_id")) { page_id = bundle.getString("page_id"); new ShowGridPhoto().execute(page_id, null); } else if (this.getIntent().hasExtra("module_id")) { album_id = bundle.getString("album_id"); module_id = bundle.getString("module_id"); group_id = bundle.getString("group_id"); new ShowGridPhoto().execute(group_id, album_id); } else { new ShowGridPhoto().execute(null, null); } } // Set a listener to be invoked when the list should be refreshed. mPullRefreshGridView.setOnRefreshListener(new OnRefreshListener2<GridView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<GridView> refreshView) { stringArrayList = null; imageUrls = null; imagePager = null; imagePhotoIds = null; imageHasLike = null; imageFeedisLike = null; imageTotal_like = null; imageTotal_comment = null; imageItemid = null; imageType = null; page = 1; adapter = new ImageAdapter(); totalImages = 1; if (album_user_id != null) { new ShowGridPhoto().execute(album_user_id, album_id); } else if (module_id != null) { new ShowGridPhoto().execute(group_id, album_id); } else if (page_id != null) { new ShowGridPhoto().execute(page_id, null); } else if (user_id != null) { new ShowGridPhoto().execute(user_id, null); } else { new ShowGridPhoto().execute(null, null); } mPullRefreshGridView.onRefreshComplete(); } @Override public void onPullUpToRefresh(PullToRefreshBase<GridView> refreshView) { if (album_user_id != null) { if (countImage < 2) { itemView = (int) (20 * (countImage)); } else { countImage = countImage - 1; itemView = itemView + 20; } adapter.notifyDataSetChanged(); mPullRefreshGridView.onRefreshComplete(); } else { if (viewmore != 1) { page++; if (module_id != null) { new ShowGridPhoto().execute(group_id, album_id); } else if (page_id != null) { new ShowGridPhoto().execute(page_id, null); } else if (user_id != null) { new ShowGridPhoto().execute(user_id, null); } else { new ShowGridPhoto().execute(null, null); } } else { mPullRefreshGridView.onRefreshComplete(); } } } }); tv = new TextView(this); tv.setGravity(Gravity.CENTER); tv.setVisibility(View.GONE); mPullRefreshGridView.setEmptyView(tv); }
From source file:com.anjuke.library.uicomponent.slidingtab.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from www . j a v a 2 s . com tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:at.wada811.android.dialogfragments.sample.alertdialogfragment.AlertDialogFragmentExamplesFragment.java
@Override public DialogFragmentCallback getDialogFragmentCallback() { return new SimpleDialogFragmentCallback() { @Override/*w w w .j av a2 s . c o m*/ public void onShow(DialogFragmentInterface dialog) { String text = "onShow"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onCancel(DialogFragmentInterface dialog) { String text = "onCancel"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onDismiss(DialogFragmentInterface dialog) { String text = "onDismiss"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onClickPositive(DialogFragmentInterface dialog) { String text = "onClickPositive"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onClickNeutral(DialogFragmentInterface dialog) { String text = "onClickNeutral"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onClickNegative(DialogFragmentInterface dialog) { String text = "onClickNegative"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public boolean onKey(DialogFragmentInterface dialog, int keyCode, KeyEvent event) { String text = "onKey[keyCode: " + keyCode + ", KeyEvent: " + event + "]"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); return false; } @Override public void onItemClick(DialogFragmentInterface dialog, int position) { Bundle extra = dialog.getExtra(); String[] items = extra.getStringArray("items"); String text = "onItemClick[position: " + position + ", item: " + items[position] + "]"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public ListAdapter getAdapter(DialogFragmentInterface dialog) { String[] items = new String[] { AlertDialog.class.getSimpleName(), CharacterPickerDialog.class.getSimpleName(), ProgressDialog.class.getSimpleName(), DatePickerDialog.class.getSimpleName(), TimePickerDialog.class.getSimpleName(), }; Bundle extra = new Bundle(); extra.putStringArray("items", items); dialog.setExtra(extra); return new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, items); } @Override public void onSingleChoiceClick(DialogFragmentInterface dialog, int position) { Bundle extra = dialog.getExtra(); String[] items = extra.getStringArray("items"); String text = "onItemClick[position: " + position + ", item: " + items[position] + "]"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public void onMultiChoiceClick(DialogFragmentInterface dialog, int position, boolean isChecked) { Bundle extra = dialog.getExtra(); String[] items = extra.getStringArray("items"); String text = "onItemClick[position: " + position + ", item: " + items[position] + ", isChecked: " + isChecked + "]"; Log.v(dialog.getTag(), text); Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show(); } @Override public View getCustomTitle(DialogFragmentInterface dialog) { TextView titleView = new TextView(getActivity()); titleView.setText(dialog.getTag()); titleView.setPadding(0, 24, 0, 24); titleView.setGravity(Gravity.CENTER); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); return titleView; } @Override public View getView(DialogFragmentInterface dialog) { ImageView imageView = new ImageView(getActivity()); imageView.setImageResource(R.drawable.ic_launcher); imageView.setPadding(0, 24, 0, 24); return imageView; } }; }
From source file:com.example.drugsformarinemammals.ViewPager_Pinnipeds.java
private void displayMessage(String messageTitle, String message) { AlertDialog.Builder myalert = new AlertDialog.Builder(this); TextView title = new TextView(this); title.setTypeface(Typeface.SANS_SERIF); title.setTextSize(20);/*w ww . ja v a2 s .co m*/ title.setTextColor(getResources().getColor(R.color.blue)); title.setPadding(8, 8, 8, 8); title.setText(""); title.setGravity(Gravity.CENTER_VERTICAL); LinearLayout layout = new LinearLayout(this); TextView text = new TextView(this); text.setTypeface(Typeface.SANS_SERIF); text.setTextSize(20); text.setPadding(10, 10, 10, 10); text.setText(message); layout.addView(text); myalert.setView(layout); myalert.setCustomTitle(title); myalert.setCancelable(true); myalert.show(); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppObj.java
@Override public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) { PackageManager pm = context.getPackageManager(); Drawable icon = null;//from w ww .j ava2 s.c o m String appName; if (obj.getJson() != null && obj.getJson().has(ANDROID_PACKAGE_NAME)) { appName = obj.getJson().optString(ANDROID_PACKAGE_NAME); } else { appName = "Unknown"; } if (!(obj instanceof DbObj)) { if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } String text = "Preparing application " + appName + "..."; // TODO: Show Market icon or app icon. TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); return; } DbObj dbParentObj = (DbObj) obj; boolean rendered = false; Intent launch = getLaunchIntent(context, dbParentObj); List<ResolveInfo> infos = pm.queryIntentActivities(launch, 0); if (infos.size() > 0) { ResolveInfo info = infos.get(0); if (info.activityInfo.labelRes != 0) { appName = info.activityInfo.loadLabel(pm).toString(); icon = info.loadIcon(pm); } else { appName = info.activityInfo.name; } } else { appName = obj.getJson().optString(ANDROID_PACKAGE_NAME); if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } } // TODO: Safer reference to containing view if (icon != null) { View parentView = (View) frame.getParent().getParent(); ImageView avatar = (ImageView) parentView.findViewById(R.id.icon); avatar.setImageDrawable(icon); TextView label = (TextView) parentView.findViewById(R.id.name_text); label.setText(appName); } // TODO: obj.getLatestChild().render(); String selection = getRenderableClause(); String[] selectionArgs = null; Cursor cursor = dbParentObj.getSubfeed().query(selection, selectionArgs); if (cursor.moveToFirst()) { DbObj dbObj = App.instance().getMusubi().objForCursor(cursor); DbObjects.getFeedRenderer(dbObj.getType()).render(context, frame, dbObj, allowInteractions); rendered = true; } if (!rendered) { String text; if (icon != null) { ImageView iv = new ImageView(context); iv.setImageDrawable(icon); iv.setAdjustViewBounds(true); iv.setMaxWidth(60); iv.setMaxHeight(60); iv.setLayoutParams(CommonLayouts.WRAPPED); frame.addView(iv); text = appName; } else { text = "New application: " + appName + "."; } // TODO: Show Market icon or app icon. TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } }
From source file:com.astuetz.pagersslidingtabstrip.PagerSlidingTabStrip.java
/** Icon is added here.*/ private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/* www. ja v a2 s.co m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.altitudelabs.swiftcart.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from www. j ava 2 s . c o m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextSize(getResources().getDimension(R.dimen.pager_tab_strip_slider_textsize)); tab.setTextColor(getResources().getColor(R.color.pager_tab_strip_text_color)); addTab(position, tab); }
From source file:PagerSlidingTab.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/* w w w. j a v a2 s. co m*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1)); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }