List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:cn.com.incito.driver.UI.detailDialog.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/* ww w.j a v a 2 s . com*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1)); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.abcs.huaqiaobang.tljr.news.tabs.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w ww . j a v a 2 s. c o m tab.setGravity(Gravity.CENTER); // DisplayMetrics dm = getResources().getDisplayMetrics(); // tab.setWidth(dm.widthPixels*2/3); tab.setSingleLine(); addTab(position, tab); }
From source file:asia.utopia.musicoff.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from ww w.j a va2 s.co m 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:com.infthink.demo.webrtc.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); setContentView(R.layout.activity_fullscreen); // init flint related String APPLICATION_ID = "~flint_android_webrtc_demo"; Flint.FlintApi.setApplicationId(APPLICATION_ID); mWebrtcChannel = new MyWebrtcChannel(); mMediaRouter = MediaRouter.getInstance(getApplicationContext()); mMediaRouteSelector = new MediaRouteSelector.Builder() .addControlCategory(FlintMediaControlIntent.categoryForFlint(APPLICATION_ID)).build(); mMediaRouterCallback = new MediaRouterCallback(); mFlingListener = new FlingListener(); mConnectionCallbacks = new ConnectionCallbacks(); mIceConnected = false;/* w ww . ja v a 2s . com*/ // init views mRootView = findViewById(android.R.id.content); mEncoderStatView = (TextView) findViewById(R.id.encoder_stat); mMenuBar = findViewById(R.id.menubar_fragment); mRoomName = (TextView) findViewById(R.id.room_name); mVideoView = (GLSurfaceView) findViewById(R.id.glview); mMediaRouteButton = (MediaRouteButton) mMenuBar.findViewById(R.id.media_route_button); mMediaRouteButton.setRouteSelector(mMediaRouteSelector); VideoRendererGui.setView(mVideoView); mScalingType = ScalingType.SCALE_ASPECT_FILL; mRemoteRender = VideoRendererGui.create(0, 0, 100, 100, mScalingType, false); mLocalRender = VideoRendererGui.create(0, 0, 100, 100, mScalingType, true); mVideoView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int visibility = mMenuBar.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE; mEncoderStatView.setVisibility(visibility); mMenuBar.setVisibility(visibility); mRoomName.setVisibility(visibility); if (visibility == View.VISIBLE) { mEncoderStatView.bringToFront(); mMenuBar.bringToFront(); mRoomName.bringToFront(); mRootView.invalidate(); } } }); ((ImageButton) findViewById(R.id.button_disconnect)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logAndToast("Disconnecting call."); disconnect(); } }); ((ImageButton) findViewById(R.id.button_switch_camera)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mPeerConn != null) { mPeerConn.switchCamera(); } } }); ((ImageButton) findViewById(R.id.button_toggle_debug)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int visibility = mHudView.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE; mHudView.setVisibility(visibility); // use this to send view switch if (mApiClient != null && mApiClient.isConnected()) { mWebrtcChannel.sendSwitchView(mApiClient); } } }); mVideoScalingButton = (ImageButton) findViewById(R.id.button_scaling_mode); mVideoScalingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mScalingType == ScalingType.SCALE_ASPECT_FILL) { mVideoScalingButton.setBackgroundResource(R.drawable.ic_action_full_screen); mScalingType = ScalingType.SCALE_ASPECT_FIT; } else { mVideoScalingButton.setBackgroundResource(R.drawable.ic_action_return_from_full_screen); mScalingType = ScalingType.SCALE_ASPECT_FILL; } updateVideoView(); } }); mHudView = new TextView(this); mHudView.setTextColor(Color.BLACK); mHudView.setBackgroundColor(Color.WHITE); mHudView.setAlpha(0.4f); mHudView.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5); mHudView.setVisibility(View.INVISIBLE); addContentView(mHudView, mHudLayout); // Create and audio manager that will take care of audio routing, // audio modes, audio device enumeration etc. mAudioManager = AppRTCAudioManager.create(this); // ready to init webrtc params mWebrtcHelper = new WebRtcHelper(this); mWebrtcHelper.initParams(); }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE IMAGE ROW/*from www . j ava2 s . c o m*/ * @param att * @param linear * @return */ public LinearLayout getDoubleImageRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(3, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams value_one_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46, 0.35f); ImageView img1 = new ImageView(context); String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value1")); img1.setImageResource(context.getResources().getIdentifier(path, null, null)); img1.setPadding(0, 3, 0, 3); container_layout.addView(img1, value_one_params); LinearLayout.LayoutParams value_two_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46, 0.35f); ImageView img2 = new ImageView(context); path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value2")); img2.setImageResource(context.getResources().getIdentifier(path, null, null)); img2.setPadding(0, 3, 0, 3); container_layout.addView(img2, value_two_params); linear.addView(container_layout); return linear; }
From source file:org.quantumbadger.redreader.activities.InboxListingActivity.java
private void makeFirstRequest(final Context context) { final RedditAccount user = RedditAccountManager.getInstance(context).getDefaultAccount(); final CacheManager cm = CacheManager.getInstance(context); final URI url; if (!isModmail) { url = Constants.Reddit.getUri("/message/inbox.json?mark=true&limit=100"); } else {/*from w w w . j av a 2 s .c o m*/ url = Constants.Reddit.getUri("/message/moderator.json?limit=100"); } // TODO parameterise limit request = new CacheRequest(url, user, null, Constants.Priority.API_INBOX_LIST, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.INBOX_LIST, true, true, true, context) { @Override protected void onDownloadNecessary() { } @Override protected void onDownloadStarted() { } @Override protected void onCallbackException(final Throwable t) { request = null; BugReportActivity.handleGlobalError(context, t); } @Override protected void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { request = null; if (loadingView != null) loadingView.setDone(R.string.download_failed); final RRError error = General.getGeneralErrorForFailure(context, type, t, status, url.toString()); AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { public void run() { notifications.addView(new ErrorView(InboxListingActivity.this, error)); } }); if (t != null) t.printStackTrace(); } @Override protected void onProgress(final boolean authorizationInProgress, final long bytesRead, final long totalBytes) { } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, final long timestamp, final UUID session, final boolean fromCache, final String mimetype) { request = null; } @Override public void onJsonParseStarted(final JsonValue value, final long timestamp, final UUID session, final boolean fromCache) { if (loadingView != null) loadingView.setIndeterminate(R.string.download_downloading); // TODO pref (currently 10 mins) // TODO xml if (fromCache && RRTime.since(timestamp) > 10 * 60 * 1000) { AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { public void run() { final TextView cacheNotif = new TextView(context); cacheNotif.setText(context.getString(R.string.listing_cached) + RRTime.formatDateTime(timestamp, context)); final int paddingPx = General.dpToPixels(context, 6); final int sidePaddingPx = General.dpToPixels(context, 10); cacheNotif.setPadding(sidePaddingPx, paddingPx, sidePaddingPx, paddingPx); cacheNotif.setTextSize(13f); notifications.addView(cacheNotif); adapter.notifyDataSetChanged(); } }); } // TODO {"error": 403} is received for unauthorized subreddits try { final JsonBufferedObject root = value.asObject(); final JsonBufferedObject data = root.getObject("data"); final JsonBufferedArray children = data.getArray("children"); for (JsonValue child : children) { final RedditThing thing = child.asObject(RedditThing.class); switch (thing.getKind()) { case COMMENT: final RedditPreparedComment comment = new RedditPreparedComment( InboxListingActivity.this, thing.asComment(), timestamp, false, null, user, headerItems); itemHandler.sendMessage(General.handlerMessage(0, comment)); break; case MESSAGE: final RedditPreparedMessage message = new RedditPreparedMessage( InboxListingActivity.this, thing.asMessage(), timestamp); itemHandler.sendMessage(General.handlerMessage(0, message)); if (message.src.replies != null && message.src.replies.getType() == JsonValue.Type.OBJECT) { final JsonBufferedArray replies = message.src.replies.asObject().getObject("data") .getArray("children"); for (JsonValue childMsgValue : replies) { final RedditMessage childMsgRaw = childMsgValue.asObject(RedditThing.class) .asMessage(); final RedditPreparedMessage childMsg = new RedditPreparedMessage( InboxListingActivity.this, childMsgRaw, timestamp); itemHandler.sendMessage(General.handlerMessage(0, childMsg)); } } break; default: throw new RuntimeException("Unknown item in list."); } } } catch (Throwable t) { notifyFailure(RequestFailureType.PARSE, t, null, "Parse failure"); return; } if (loadingView != null) loadingView.setDone(R.string.download_done); } }; cm.makeRequest(request); }
From source file:com.TakeTaxi.jy.OnrouteScreen.java
public void pingpicked(JSONObject json) { try {/* w w w .jav a 2 s. c om*/ int driverpicked = json.getInt("picked"); int drivercancelled = json.getInt("dcancel"); int starttime = json.getInt("datetime"); // /////////////////////////////// DRIVER CANCEL //////// if (drivercancelled == 1) { // //// DRIVER CANCEL LATE ///// if (starttime + 300 <= Query.getServerTime()) { handlerboolean = false; handler.removeCallbacks(r); AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create(); dcancelbuilder .setMessage("Job has been cancelled.\nWould you like to report a late cancellation?."); // //// DRIVER CANCEL LATE - NO REPORT LATE///// button_cancelJob_noquery(dcancelbuilder); // //// DRIVER CANCEL LATE - REPORT LATE ///// button_drivercancel_reportlate(dcancelbuilder); dcancelbuilder.show(); } else { // /////////////////////////////// DRIVER CANCEL NO ALERTS - // WITHIN TIME LIMIT/////////////// handlerboolean = false; handler.removeCallbacks(r); alertdialog_drivercancelintime(); } } if (driverpicked == 1) { // /////////////////////////////// CONFIRM PICK UP // /////////////////////////////////////////// handlerboolean = false; handler.removeCallbacks(r); AlertDialog.Builder alert = new AlertDialog.Builder(OnrouteScreen.this); final Drawable thumbsup = getResources().getDrawable(R.drawable.thumbsup); final Drawable thumbsupwhite = getResources().getDrawable(R.drawable.thumbsupwhite); final Drawable thumbsdown = getResources().getDrawable(R.drawable.thumbsdown); final Drawable thumbsdownwhite = getResources().getDrawable(R.drawable.thumbsdownwhite); LinearLayout layout = new LinearLayout(OnrouteScreen.this); layout.setOrientation(1); layout.setGravity(17); TextView tx1 = new TextView(OnrouteScreen.this); tx1.setText("Driver says you have been picked up"); tx1.setGravity(17); tx1.setTextSize(20); tx1.setTextColor(Color.WHITE); tx1.setPadding(10, 10, 10, 10); TextView tx2 = new TextView(OnrouteScreen.this); tx2.setText("Please rate your driver"); tx2.setGravity(17); tx2.setTextSize(16); LinearLayout imglayout = new LinearLayout(OnrouteScreen.this); imglayout.setOrientation(0); imglayout.setGravity(17); final ImageView ivup = new ImageView(OnrouteScreen.this); ivup.setImageDrawable(thumbsupwhite); ivup.setClickable(true); ivup.setPadding(0, 5, 30, 5); final ImageView ivdown = new ImageView(OnrouteScreen.this); ivdown.setImageDrawable(thumbsdownwhite); ivdown.setClickable(true); ivup.setPadding(30, 5, 0, 5); imglayout.addView(ivup); imglayout.addView(ivdown); layout.addView(tx1); layout.addView(tx2); layout.addView(imglayout); // /////////////////////////////// CONFIRM PICK UP - RATINGS // /////////////////////////////////////////// ivup.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsupboolean == false) { thumbsupboolean = true; thumbsdownboolean = false; ivup.setImageDrawable(thumbsup); ivdown.setImageDrawable(thumbsdownwhite); rating = 1; } else { thumbsupboolean = false; ivup.setImageDrawable(thumbsupwhite); rating = 0; } } }); ivdown.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsdownboolean == false) { thumbsdownboolean = true; thumbsupboolean = false; ivdown.setImageDrawable(thumbsdown); ivup.setImageDrawable(thumbsupwhite); AlertDialog alert = new AlertDialog.Builder(OnrouteScreen.this).create(); alert.setMessage("Please pick one"); alert.setButton("No show", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -1; } }); alert.setButton2("Driver late", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -2; } }); alert.setButton3("Poor service", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -3; } }); alert.show(); } else { thumbsupboolean = false; ivdown.setImageDrawable(thumbsdownwhite); rating = 0; } } }); button_completed_finish(alert); alert.setView(layout); alert.create(); alert.show(); } else { } } catch (JSONException e) { } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the image cache text view.// w w w. j a v a 2s . c o m * * @return the text view */ private TextView createCacheText() { TextView cacheText = new TextView(this); cacheText.setPadding(10, 5, 0, 5); cacheText.setText("Image Cache:"); cacheText.setBackgroundColor(Color.DKGRAY); return cacheText; }
From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/* ww w .j a v a 2s .c o m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.example.samsungmdm.MainActivity.java
public void onServerResponse(String response) { TextView serverResponseTextView = new TextView(this); serverResponseTextView.setHorizontallyScrolling(true); serverResponseTextView.setSingleLine(); serverResponseTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE); serverResponseTextView.setFocusableInTouchMode(true); serverResponseTextView.setMarqueeRepeatLimit(1); serverResponseTextView.setFocusable(true); String myTime = java.text.DateFormat.getTimeInstance().format(Calendar.getInstance().getTime()); serverResponseTextView.setText(myTime + " - " + response); mServerResponseLinearLayout.addView(serverResponseTextView, 0); //Parsing server response try {/*from w ww.j a v a 2 s .c o m*/ parseServerResponse(new JSONObject(response)); } catch (JSONException e) { Log.e(TAG, "Invalid JSON response from the server"); e.printStackTrace(); } }