List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:com.manning.androidhacks.hack005.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from ww w . j a v a 2 s . co m mTextSwitcher = (TextSwitcher) findViewById(R.id.your_textview); mTextSwitcher.setFactory(new ViewFactory() { @Override public View makeView() { TextView t = new TextView(MainActivity.this); t.setGravity(Gravity.CENTER); return t; } }); mTextSwitcher.setInAnimation(this, android.R.anim.fade_in); mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out); onSwitchText(null); }
From source file:com.collcloud.frame.viewpager.main.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/*from www .j av a 2 s .c om*/ final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); v.setBackgroundResource(R.drawable.tab_pagertab_background_card); v.setText("CARD is " + (position + 1)); fl.addView(v); return fl; }
From source file:org.ligi.android.dubwise_uavtalk.dashboard.DownloadDashboardImagesStatusAlertDialog.java
/** * /*from www . j a v a 2 s .c o m*/ * @param activity * @param autoclose - if the alert should close when connection is established * */ public static void show(Context activity, boolean autoclose, Intent after_connection_intent) { LinearLayout lin = new LinearLayout(activity); lin.setOrientation(LinearLayout.VERTICAL); ScrollView sv = new ScrollView(activity); TextView details_text_view = new TextView(activity); LinearLayout lin_in_scrollview = new LinearLayout(activity); lin_in_scrollview.setOrientation(LinearLayout.VERTICAL); sv.addView(lin_in_scrollview); lin_in_scrollview.addView(details_text_view); details_text_view.setText("no text"); ProgressBar progress = new ProgressBar(activity, null, android.R.attr.progressBarStyleHorizontal); progress.setMax(img_lst.length); lin.addView(progress); lin.addView(sv); new AlertDialog.Builder(activity).setTitle("Download Status").setView(lin) .setPositiveButton("OK", new DialogDiscardingOnClickListener()).show(); class AlertDialogUpdater implements Runnable { private Handler h = new Handler(); private TextView myTextView; private ProgressBar myProgress; public AlertDialogUpdater(TextView ab, ProgressBar progress) { myTextView = ab; myProgress = progress; } public void run() { for (int i = 0; i < img_lst.length; i++) { class MsgUpdater implements Runnable { private int i; public MsgUpdater(int i) { this.i = i; } public void run() { myProgress.setProgress(i + 1); if (i != img_lst.length - 1) myTextView.setText("Downloading " + img_lst[i] + ".png"); else myTextView.setText("Ready - please restart DUBwise to apply changes!"); } } h.post(new MsgUpdater(i)); try { URLConnection ucon = new URL(url_lst[i]).openConnection(); BufferedInputStream bis = new BufferedInputStream(ucon.getInputStream()); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) baf.append((byte) current); File path = new File( Environment.getExternalStorageDirectory() + "/dubwise/images/dashboard"); path.mkdirs(); FileOutputStream fos = new FileOutputStream( new File(path.getAbsolutePath() + "/" + img_lst[i] + ".png")); fos.write(baf.toByteArray()); fos.close(); } catch (Exception e) { } try { Thread.sleep(199); } catch (InterruptedException e) { } } } } new Thread(new AlertDialogUpdater(details_text_view, progress)).start(); }
From source file:com.aaagame.proframework.fragment.T_PaletteFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);// w w w . j av a2s .com fl.setBackgroundResource(drawables[position]); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.BOTTOM); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.baidao.realm_threadexample.AsyncTaskFragment.java
private void showStatus(String txt) { Log.i(TAG, txt);//from w w w .java 2 s . c o m TextView tv = new TextView(getActivity()); tv.setText(txt); tv.setTextColor(getResources().getColor(android.R.color.white)); logsView.addView(tv); }
From source file:com.commonsware.android.arXiv.arXiv.java
private boolean applyMenuChoice(MenuItem item) { switch (item.getItemId()) { case ABOUT_ID: String str = getString(R.string.about_text); TextView wv = new TextView(this); wv.setPadding(16, 0, 16, 16);//from w w w. j ava 2 s .c o m wv.setText(str); ScrollView scwv = new ScrollView(this); scwv.addView(wv); Dialog dialog = new Dialog(this) { public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode != KeyEvent.KEYCODE_DPAD_LEFT) this.dismiss(); return true; } }; dialog.setTitle(R.string.about_arxiv_droid); dialog.addContentView(scwv, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); dialog.show(); return (true); case HISTORY_ID: Intent myIntent = new Intent(this, DownloadsActivity.class); startActivity(myIntent); return (true); case PREF_ID: if (Build.VERSION.SDK_INT >= 11) { startActivity(new Intent(this, EditPreferences.class)); } else { startActivity(new Intent(this, EditPreferencesCompat.class)); } return (true); case DONATE_ID: Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.jd.android.arXiv")); try { startActivity(goToMarket); } catch (Exception ef) { Toast.makeText(this, "Market Not Installed", Toast.LENGTH_SHORT).show(); } return (true); case SEARCH_ID: Intent search = new Intent(this, SearchWindow.class); startActivity(search); return (true); } return (false); }
From source file:com.manning.androidhacks.hack004.preference.AboutDialog.java
@Override protected View onCreateDialogView() { LinearLayout layout = new LinearLayout(mContext); layout.setOrientation(LinearLayout.VERTICAL); TextView splashText = new TextView(mContext); String fmt = "Version %s<br />" + "<a href=\"http://manning.com/sessa\">MoreInfo</a>"; try {// ww w . j a v a 2s.com String pkg = mContext.getPackageName(); mVersionNumber = mContext.getPackageManager().getPackageInfo(pkg, 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } if (mVersionNumber != null) { String aboutMsg = String.format(fmt, mVersionNumber); splashText.setText(Html.fromHtml(aboutMsg)); splashText.setMovementMethod(LinkMovementMethod.getInstance()); } layout.addView(splashText); return layout; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.PhoneStateObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from ww w . j av a 2 s . c o m*/ TextView valueTV = new TextView(context); valueTV.setText(asText(content)); 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:edu.stanford.mobisocial.dungbeetle.feed.objects.FeedRefObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w w w. ja v a2 s.co m byte[] raw = obj.getRaw(); TextView view = new TextView(context); view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); String feedName = content.optString(FEED_ID); view.setText(feedName); view.setBackgroundColor(Feed.colorFor(feedName)); frame.addView(view); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.StatusObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w w w . ja v a 2s . c o m TextView valueTV = new TextView(context); valueTV.setText(content.optString(TEXT)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); if (Linkify.addLinks(valueTV, Linkify.ALL)) { if (!allowInteractions) valueTV.setMovementMethod(null); } frame.addView(valueTV); }