List of usage examples for android.widget TextView TextView
public TextView(Context context)
From source file:com.vrem.wifianalyzer.wifi.channelrating.ChannelRatingAdapterTest.java
@Before public void setUp() { mainActivity = RobolectricUtil.INSTANCE.getActivity(); channelRating = mock(ChannelRating.class); bestChannels = new TextView(mainActivity); settings = MainContextHelper.INSTANCE.getSettings(); fixture = new ChannelRatingAdapter(mainActivity, bestChannels); fixture.setChannelRating(channelRating); }
From source file:com.example.android.MainActivity.java
/**Display JSON data in table format on the user interface of android app * by clicking on the button 'Start'*/ @Override// www .j a v a 2s . c o m protected void onCreate(Bundle savedInstanceState) { /** * Declares TextView, Button and Tablelayout to retrieve the widgets * from User Interface. Insert the TableRow into Table and set the * gravity, font size and id of table rows and columns. * * Due to great amount of JSON data, 'for' loop method is used to insert * the new rows and columns in the table. In each loop, each of rows and * columns are set to has its own unique id. This purpose of doing this * is to allows the user to read and write the text of specific rows and * columns easily. */ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progress = new ProgressDialog(this); StartDisplay = (Button) findViewById(R.id.btnDisplay); profile = (TableLayout) findViewById(R.id.tableLayout1); profile.setStretchAllColumns(true); profile.bringToFront(); for (int i = 1; i < 11; i++) { TableRow tr = new TableRow(this); TextView c1 = new TextView(this); TextView c2 = new TextView(this); c1.setId(i * 10 + 1); c1.setTextSize(12); c1.setGravity(Gravity.CENTER); c2.setId(i * 10 + 2); c2.setTextSize(12); c2.setGravity(Gravity.CENTER); tr.addView(c1); tr.addView(c2); tr.setGravity(Gravity.CENTER_HORIZONTAL); profile.addView(tr); } /** * onClick: Executes the DownloadWebPageTask once OnClick event occurs. * When user click on the "Start" button, * 1)the JSON data will be read from URL * 2)Progress bar will be shown till all data is read and displayed in * table form. Once it reaches 100%, it will be dismissed. * * Progress Bar: The message of the progress bar is obtained from strings.xml. * New thread is created to handle the action of the progress bar. */ StartDisplay.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final String TAG = "MyActivity"; progress.setMessage(getResources().getString(R.string.ProgressBar_message)); progress.setCancelable(true); progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progress.setProgress(0); progress.setMax(100); progress.show(); new Thread(new Runnable() { public void run() { while (ProgressBarStatus < 100) { try { Thread.sleep(500); } catch (InterruptedException e) { Log.e(TAG, Log.getStackTraceString(e)); } progressBarbHandler.post(new Runnable() { public void run() { progress.setProgress(ProgressBarStatus); } }); } if (ProgressBarStatus >= 100) { try { Thread.sleep(1000); } catch (InterruptedException e) { Log.e(TAG, Log.getStackTraceString(e)); } progress.dismiss(); } } }).start(); DownloadWebPageTask task = new DownloadWebPageTask(); task.execute("http://private-ae335-pgserverapi.apiary.io/user/profile/234"); StartDisplay.setClickable(false); } }); }
From source file:at.wada811.android.dialogfragments.sample.dialogfragmentcallbackprovider.DialogFragmentCallbackProviderFragment.java
@Override public DialogFragmentCallback getDialogFragmentCallback() { return new SimpleDialogFragmentCallback() { @Override/*w w w. jav a 2s . c o m*/ public View getView(DialogFragmentInterface dialog) { TextView titleView = new TextView(getActivity()); titleView.setText("Use getChildFragmentManager()"); titleView.setPadding(0, 24, 0, 24); titleView.setGravity(Gravity.CENTER); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); return titleView; } }; }
From source file:com.mikecorrigan.trainscorekeeper.ActivityNewGame.java
private void addContent() { Log.vc(VERBOSE, TAG, "addContent"); LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linear_layout); Resources res = getResources(); AssetManager am = res.getAssets();//w w w . j a v a2s . c o m String files[]; try { files = am.list(ASSETS_BASE); if (files == null || files.length == 0) { Log.e(TAG, "addContent: empty asset list"); return; } for (final String file : files) { final String path = ASSETS_BASE + File.separator + file; JSONObject jsonRoot = JsonUtils.readFromAssets(this /* context */, path); if (jsonRoot == null) { Log.e(file, "addContent: failed to read read asset"); continue; } final String name = jsonRoot.optString(JsonSpec.ROOT_NAME); if (TextUtils.isEmpty(name)) { Log.e(file, "addContent: failed to read asset name"); continue; } final String description = jsonRoot.optString(JsonSpec.ROOT_DESCRIPTION, name); TextView textView = new TextView(this /* context */); textView.setText(name); linearLayout.addView(textView); Button button = new Button(this /* context */); button.setText(description); button.setOnClickListener(new OnRulesClickListener(path)); linearLayout.addView(button); } } catch (IOException e) { Log.th(TAG, e, "addContent: asset list failed"); } }
From source file:com.df.kia.carsWaiting.CarsWaitingListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cars_waiting); swipeListView = (SwipeListView) findViewById(R.id.carsWaitingList); data = new ArrayList<CarsWaitingItem>(); adapter = new CarsWaitingListAdapter(this, data, new CarsWaitingListAdapter.OnAction() { @Override/*from ww w . j a v a2s. c o m*/ public void onEditPressed(int position) { swipeListView.openAnimate(position); } @Override public void onModifyProcedure(int positon) { CarsWaitingItem item = data.get(positon); Intent intent = new Intent(CarsWaitingListActivity.this, InputProceduresActivity.class); intent.putExtra("carId", item.getCarId()); startActivity(intent); } @Override public void onDeleteCar(final int position) { View view1 = getLayoutInflater().inflate(R.layout.popup_layout, null); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); TextView content = new TextView(view1.getContext()); content.setText(R.string.confirmDeleteCar); content.setTextSize(20f); contentArea.addView(content); setTextView(view1, R.id.title, getResources().getString(R.string.alert)); AlertDialog dialog = new AlertDialog.Builder(CarsWaitingListActivity.this).setView(view1) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { CarsWaitingItem item = data.get(position); deleteCar(item.getCarId()); } }).setNegativeButton(R.string.cancel, null).create(); dialog.show(); } }); swipeListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() { @Override public void onClickFrontView(int position) { getCarDetail(data.get(position).getCarId(), CarCheckActivity.class); } @Override public void onDismiss(int[] reverseSortedPositions) { for (int position : reverseSortedPositions) { data.remove(position); } adapter.notifyDataSetChanged(); } @Override public void onStartOpen(int position, int action, boolean right) { swipeListView.closeOpenedItems(); lastPos = position; } }); swipeListView.setSwipeMode(SwipeListView.SWIPE_MODE_LEFT); swipeListView.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_REVEAL); swipeListView.setLongClickable(false); swipeListView.setSwipeOpenOnLongPress(false); swipeListView.setOffsetLeft(620); swipeListView.setAnimationTime(300); swipeListView.setAdapter(adapter); footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.footer, null, false); swipeListView.addFooterView(footerView); Button homeButton = (Button) findViewById(R.id.buttonHome); homeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); Button loadMoreButton = (Button) findViewById(R.id.loadMore); loadMoreButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { refresh(); } }); Button refreshButton = (Button) findViewById(R.id.buttonRefresh); refreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startNumber = 1; data.clear(); adapter.notifyDataSetChanged(); swipeListView.closeOpenedItems(); refresh(); } }); refresh(); }
From source file:com.acious.android.paginationseekbar.internal.Marker.java
public Marker(Context context, AttributeSet attrs, int defStyleAttr, String maxValue) { super(context, attrs, defStyleAttr); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PaginationSeekBar, R.attr.paginationSeekBarStyle, R.style.DefaultSeekBar); int padding = (int) (PADDING_DP * displayMetrics.density) * 2; int textAppearanceId = a.getResourceId(R.styleable.PaginationSeekBar_psb_indicatorTextAppearance, R.style.DefaultIndicatorTextAppearance); mNumber = new TextView(context); //Add some padding to this textView so the bubble has some space to breath mNumber.setPadding(padding, 0, padding, 0); mNumber.setTextAppearance(context, textAppearanceId); mNumber.setGravity(Gravity.CENTER);//ww w . j a v a2 s. co m mNumber.setText(maxValue); mNumber.setMaxLines(1); mNumber.setSingleLine(true); SeekBarCompat.setTextDirection(mNumber, TEXT_DIRECTION_LOCALE); mNumber.setVisibility(View.INVISIBLE); //add some padding for the elevation shadow not to be clipped //I'm sure there are better ways of doing this... setPadding(padding, padding, padding, padding); resetSizes(maxValue); mSeparation = (int) (SEPARATION_DP * displayMetrics.density); int thumbSize = (int) (ThumbDrawable.DEFAULT_SIZE_DP * displayMetrics.density); ColorStateList color = a.getColorStateList(R.styleable.PaginationSeekBar_psb_indicatorColor); mMarkerDrawable = new MarkerDrawable(color, thumbSize); mMarkerDrawable.setCallback(this); mMarkerDrawable.setMarkerListener(this); mMarkerDrawable.setExternalOffset(padding); //Elevation for anroid 5+ float elevation = a.getDimension(R.styleable.PaginationSeekBar_psb_indicatorElevation, ELEVATION_DP * displayMetrics.density); ViewCompat.setElevation(this, elevation); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SeekBarCompat.setOutlineProvider(this, mMarkerDrawable); } a.recycle(); }
From source file:at.flack.MailOutActivity.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_mail_main, container, false); loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false)); contactList = (ListView) rootView.findViewById(R.id.listview); TextView padding = new TextView(getActivity()); padding.setHeight(10);// ww w. jav a 2 s . c o m contactList.addHeaderView(padding); contactList.setHeaderDividersEnabled(false); contactList.setFooterDividersEnabled(false); progressbar = rootView.findViewById(R.id.load_screen); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab); fab.attachToListView(contactList); fab.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent newMail = new Intent(getActivity(), NewMailActivity.class); getActivity().startActivity(newMail); } }); progressbar = rootView.findViewById(R.id.load_screen); if (mailOutList == null) progressbar.setVisibility(View.VISIBLE); updateContactList(((MainActivity) this.getActivity())); swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container); swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if (getActivity() instanceof MainActivity) { updateContactList(((MainActivity) getActivity())); } } }); contactList.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0 : contactList.getChildAt(0).getTop(); swipe.setEnabled(topRowVerticalPosition >= 0); } }); contactList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (mailOutList == null) { updateContactList((MainActivity) getActivity()); } openMessageActivity(getActivity(), arg2 - 1); } }); setRetainInstance(true); return rootView; }
From source file:com.df.app.carsWaiting.CarsWaitingListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cars_waiting); swipeListView = (SwipeListView) findViewById(R.id.carsWaitingList); data = new ArrayList<CarsWaitingItem>(); adapter = new CarsWaitingListAdapter(this, data, new CarsWaitingListAdapter.OnAction() { @Override//from ww w . j av a2 s . c o m public void onEditPressed(int position) { swipeListView.openAnimate(position); } @Override public void onModifyProcedure(int positon) { CarsWaitingItem item = data.get(positon); Intent intent = new Intent(CarsWaitingListActivity.this, InputProceduresActivity.class); intent.putExtra("carId", item.getCarId()); startActivity(intent); } @Override public void onDeleteCar(final int position) { View view1 = getLayoutInflater().inflate(R.layout.popup_layout, null); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); TextView content = new TextView(view1.getContext()); content.setText(R.string.confirmDeleteCar); content.setTextSize(20f); contentArea.addView(content); setTextView(view1, R.id.title, getResources().getString(R.string.alert)); AlertDialog dialog = new AlertDialog.Builder(CarsWaitingListActivity.this).setView(view1) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { CarsWaitingItem item = data.get(position); deleteCar(item.getCarId()); } }).setNegativeButton(R.string.cancel, null).create(); dialog.show(); } }); swipeListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() { @Override public void onClickFrontView(int position) { getCarDetail(data.get(position).getCarId(), CarCheckActivity.class); } @Override public void onDismiss(int[] reverseSortedPositions) { for (int position : reverseSortedPositions) { data.remove(position); } adapter.notifyDataSetChanged(); } @Override public void onStartOpen(int position, int action, boolean right) { swipeListView.closeOpenedItems(); } }); swipeListView.setSwipeMode(SwipeListView.SWIPE_MODE_LEFT); swipeListView.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_REVEAL); swipeListView.setLongClickable(false); swipeListView.setSwipeOpenOnLongPress(false); swipeListView.setOffsetLeft(620); swipeListView.setAnimationTime(300); swipeListView.setAdapter(adapter); footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.footer, null, false); swipeListView.addFooterView(footerView); Button homeButton = (Button) findViewById(R.id.buttonHome); homeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); Button loadMoreButton = (Button) findViewById(R.id.loadMore); loadMoreButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { refresh(false); } }); Button refreshButton = (Button) findViewById(R.id.buttonRefresh); refreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { refresh(true); } }); refresh(true); }
From source file:at.flack.activity.NewSMSContactActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_new_contact); Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); setSupportActionBar(toolbar);//ww w.j av a 2 s . com getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); contactNameMap = new ContactNameMap(this); contactList = (ListView) this.findViewById(R.id.listview); TextView padding = new TextView(this); padding.setHeight(10); contactList.addHeaderView(padding); contactList.setHeaderDividersEnabled(false); contactList.addFooterView(padding, null, false); contactList.setFooterDividersEnabled(false); updateContacts(); contactList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (contacts == null) { updateContacts(); } openMessageActivity(NewSMSContactActivity.this, arg2 - 1); } }); }
From source file:at.flack.activity.NewFbContactActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_new_contact); Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); setSupportActionBar(toolbar);/*from w w w . j a v a 2 s . com*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); contactList = (ListView) this.findViewById(R.id.listview); progressbar = this.findViewById(R.id.load_screen); searchBig = this.findViewById(R.id.search_big); searchBig.setVisibility(View.VISIBLE); TextView padding = new TextView(this); padding.setHeight(10); contactList.addHeaderView(padding); contactList.setHeaderDividersEnabled(false); contactList.addFooterView(padding, null, false); contactList.setFooterDividersEnabled(false); updateContacts(null); contactList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (contacts == null) { updateContacts(null); } openMessageActivity(NewFbContactActivity.this, arg2 - 1); } }); try { fb_img = ProfilePictureCache.getInstance(this); } catch (Exception e) { e.printStackTrace(); } }