Java Code Examples for android.widget.TextView.setText()

The following are Jave code examples for showing how to use setText() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: financisto1-holo   File: AmountPicker.java   View Source Code Vote up 6 votes
public AmountPicker(Context context, int decimals) {
       super(context);
       
       integers = new NumberPicker[Math.max(0, 5-decimals)];
       fractions = new NumberPicker[decimals];
       
       int totalWidth = 6*getResources().getDimensionPixelSize(R.dimen.amount_picker_width);
       int total = integers.length + fractions.length;
       int pickerWidth = totalWidth/total;
       
       setOrientation(HORIZONTAL);                
       LinearLayout.LayoutParams lpFixedWrap = new LinearLayout.LayoutParams(pickerWidth, LayoutParams.WRAP_CONTENT);
       LinearLayout.LayoutParams lpWrapFill = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
       addPickers(context, lpFixedWrap, integers);
       if (decimals > 0) {
       	TextView dotText = new TextView(context);
       	dotText.setText(".");
       	dotText.setGravity(Gravity.BOTTOM);
       	dotText.setTextSize(pickerWidth/2);
       	addView(dotText, lpWrapFill);
       	addPickers(context, lpFixedWrap, fractions);
       }
}
 
Example 2
Project: wordstack   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN && !stackedLayout.empty()) {
        LetterTile tile = (LetterTile) stackedLayout.peek();
        tile.moveToViewGroup((ViewGroup) v);
        if (stackedLayout.empty()) {
            TextView messageBox = (TextView) findViewById(R.id.message_box);
            messageBox.setText(word1 + " " + word2);
        }
        /**
         **
         **  YOUR CODE GOES HERE
         **
         **/
        return true;
    }
    return false;
}
 
Example 3
Project: Musicoco   File: MainSheetsController.java   View Source Code Vote up 6 votes
private void updateTextAndColor(TextView categoryView, int count, TextView countView, int[] colors) {

        categoryView.setBackgroundColor(colors[2]);
        categoryView.setTextColor(colors[3]);

        GradientDrawable countD = new GradientDrawable();
        countD.setColor(colors[0]);
        countD.setCornerRadius(countView.getHeight() / 2);
        countView.setBackground(countD);
        countView.setTextColor(colors[1]);

        int c = count;
        if (countView == mCountRecent) {
            int recent = activity.getResources().getInteger(R.integer.sheet_recent_count);
            c = count > recent ? recent : c;
        }
        countView.setText(String.valueOf(c));

    }
 
Example 4
Project: mao-android   File: BillingFragment.java   View Source Code Vote up 6 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    log.i("onCreateView");
    View rootView = inflater.inflate(R.layout.fragment_billing, container, false);
    txt_content = (TextView) rootView.findViewById(R.id.txt_content);
    txt_content.setText(this.getClass().getSimpleName());
    bill_type = (Spinner) rootView.findViewById(R.id.bill_type);
    bill_sku = (Spinner) rootView.findViewById(R.id.bill_sku);
    String[] testSkus = getResources().getStringArray(R.array.bill_skus);
    for (String sku : testSkus) {
        mSkuList.add(sku);
    }
    mSkuAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, mSkuList);
    mSkuAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    bill_sku.setAdapter(mSkuAdapter);
    return rootView;
}
 
Example 5
Project: encdroidMC   File: ConfigSyncActivity.java   View Source Code Vote up 6 votes
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	super.onActivityResult(requestCode, resultCode, data);

	switch (requestCode) {
	case 0:
		TextView localFolder = (TextView) findViewById(R.id.localFolder);
		if (data==null || data.getExtras()==null) return;
		String choosedFolder = data.getExtras().getString(EDFileChooserActivity.PARAM_KEY_PATH);
		EncdroidFileProvider originProvider = (EncdroidFileProvider)data.getSerializableExtra(EDFileChooserActivity.PARAM_KEY_PROVIDER);
		String importPath = new File( originProvider.getAbsolutePath(choosedFolder)).getAbsolutePath();
		localFolder.setText(importPath);
	}
}
 
Example 6
Project: tuxguitar   File: TGBrowserSettingsFolderAdapter.java   View Source Code Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	TGBrowserSettingsFolderAdapterItem item = this.items.get(position);
	
	View view = (convertView != null ? convertView : getLayoutInflater().inflate(R.layout.view_browser_element, parent, false));
	view.setTag(item);
	
	TextView textView = (TextView) view.findViewById(R.id.tg_browser_element_name);
	textView.setText(item.getLabel());
	
	Drawable styledIcon = this.findStyledFolderIcon();
	if( styledIcon != null ) {
		ImageView imageView = (ImageView) view.findViewById(R.id.tg_browser_element_icon);
		imageView.setImageDrawable(styledIcon);
	}
	
	view.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			updatePath(((TGBrowserSettingsFolderAdapterItem) v.getTag()).getFile());
		}
	});
	
	return view;
}
 
Example 7
Project: ZhuHaiBusApplication   File: ActAdapter.java   View Source Code Vote up 6 votes
@Override
public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
    View view=layoutInflater.inflate(R.layout.item_view,null);

    TextView item=(TextView)view;
    item.setText(cursor.getString(cursor.getColumnIndex("_id")));
    TextView textView= view.findViewById(R.id.point_item_tv);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d(TAG, "onClick: select lineId is "+textView.getText());
            realTimeBusQueryActivity.lineNumber_actv.setText(textView.getText());
            realTimeBusQueryActivity.showFromAndToStation((String) textView.getText());
        }
    });
    return view;
}
 
Example 8
Project: SDK-Samples   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mMainText = (TextView) findViewById(R.id.main_text);

    // If you plan to run this application on different devices (not on YotaPhone only), you
    // may want to check if this device is YotaPhone before starting Epd activity. You could
    // use Build.DEVICE for this.
    if (!Build.DEVICE.contains(YOTAPHONE)) {
        // This device is not a YotaPhone, say "Hello! This is not a YotaPhone!"
        mMainText.setText(getString(R.string.hello_strange_phone));
    } else {
        // This device is a YotaPhone, say "Hello, YotaPhone!" and start activity on Epd screen
        mMainText.setText(getString(R.string.hello_yota_phone));
        this.startActivity(new Intent(this, EpdActivity.class));
    }
}
 
Example 9
Project: Divertio   File: MenuDrawerAdapter.java   View Source Code Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parentView) {

    // Get the parts
    menuItemLayout = (RelativeLayout) layoutInflater.inflate(R.layout.list_item_menu_drawer, parentView, false);
    ImageView imageView = (ImageView) menuItemLayout.findViewById(R.id.menu_icon);
    TextView textView = (TextView) menuItemLayout.findViewById(R.id.menu_title);

    // Set the parts equal to the corresponding part
    Drawable icon = activity.getResources().getDrawable(iconIdList[position]);
    String title = titleList[position];
    imageView.setImageDrawable(icon);
    textView.setText(title);

    // Set position as tag
    menuItemLayout.setTag(position);
    return menuItemLayout;
}
 
Example 10
Project: ConductorMVP   File: TideLocationsView.java   View Source Code Vote up 6 votes
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
  if (convertView == null) {
    convertView = inflate(getContext(), R.layout.tide_location_grid_item, null);
  }
  final TideLocations tideLocation = getItem(position);
  ImageView tideLocationImageView = (ImageView) convertView.findViewById(R.id.tideLocationImage);
  TextView tideLocationTextView = (TextView) convertView.findViewById(R.id.tideLocationName);

  tideLocationImageView.setImageResource(tideLocation.getImageId());
  tideLocationTextView.setText(tideLocation.getName());
  convertView.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View view) {
      getController().tideLocationSelected(tideLocation.getNoaaApiId(), tideLocation.getName());
    }
  });
  return convertView;
}
 
Example 11
Project: True-Weather   File: SecurityTipArea.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_security_tip_area);

    headTv= (TextView) findViewById(R.id.securityAreaHead);
    areaTv= (TextView) findViewById(R.id.securityAreaTv);
    linkTv= (TextView) findViewById(R.id.securityAreaRefTv);

    Intent intent= getIntent();
    String name= intent.getStringExtra("name");
    String data= intent.getStringExtra("data");
    final String ref= intent.getStringExtra("ref");

    headTv.setText(name);
    areaTv.setText(data);
    linkTv.setText(ref);

    linkTv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(ref.equals("None")){
                return;
            }
            Uri uri = Uri.parse(ref);
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
            SecurityTipArea.this.startActivity(browserIntent);
        }
    });

}
 
Example 12
Project: GitHub   File: Utils.java   View Source Code Vote up 5 votes
public static void setSpannableStr(TextView textView, String str, int startIndex, int endIndex, float proporation) {
    SpannableString spannableString = new SpannableString(str);
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#393939"));
    spannableString.setSpan(colorSpan, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    RelativeSizeSpan sizeSpan01 = new RelativeSizeSpan(proporation);
    spannableString.setSpan(sizeSpan01, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

    textView.setText(spannableString);
}
 
Example 13
Project: LiveGiftLayout   File: FileUtil.java   View Source Code Vote up 5 votes
public static boolean setText(View view, int id, int text) {
    TextView textView = (TextView) view.findViewById(id);
    if (textView == null)
        return false;

    textView.setText(text);
    return true;
}
 
Example 14
Project: QuanMinTV   File: EditPagePort.java   View Source Code Vote up 5 votes
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
	llBottom.addView(v, lp);
}
 
Example 15
Project: Runnest   File: DisplayUserFragment.java   View Source Code Vote up 5 votes
private void displayFoundUser(final View view, final String name, final String email) {
    if (view == null || name == null || name.equals("")) {
        throw new IllegalArgumentException();
    }

    TableLayout table = (TableLayout) view.findViewById(R.id.table);
    TableRow tableRow = new TableRow(this.getContext());
    //tableRow.setBackgroundColor(getResources().getColor(R.color.colorAccent));
    tableRow.setPadding(20, 20, 20, 5);

    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams();
    layoutParams.setMargins(50, 40, 40, 40);

    TextView nameTextView = new TextView(this.getContext());
    nameTextView.setText(name);
    nameTextView.setTextSize(22);
    nameTextView.setTextColor(getResources().getColor(R.color.cast_expanded_controller_text_color));
    nameTextView.setLayoutParams(layoutParams);
    tableRow.addView(nameTextView);

    tableRow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((SideBarActivity) getActivity()).searchViewAsMenuItem.collapseActionView();
            listener.onDisplayProfileFragmentInteraction(name, email);
        }
    });

    table.addView(tableRow);
}
 
Example 16
Project: AndroidUtilCode-master   File: ToastActivity.java   View Source Code Vote up 5 votes
@Override
public void initView(Bundle savedInstanceState, View view) {
    findViewById(R.id.btn_toggle_location).setOnClickListener(this);
    findViewById(R.id.btn_toggle_view).setOnClickListener(this);
    findViewById(R.id.btn_show_short_toast_safe).setOnClickListener(this);
    findViewById(R.id.btn_show_long_toast_safe).setOnClickListener(this);
    findViewById(R.id.btn_show_short_toast).setOnClickListener(this);
    findViewById(R.id.btn_show_long_toast).setOnClickListener(this);
    findViewById(R.id.btn_cancel_toast).setOnClickListener(this);
    tvAboutToast = (TextView) findViewById(R.id.tv_about_toast);
    tvAboutToast.setText("is default location: " + isDefaultLocation
            + "\nis default view: " + isDefaultView
    );
}
 
Example 17
Project: MADBike   File: MapFragment.java   View Source Code Vote up 4 votes
@Override
public void onInfoWindowClick(final Marker marker) {

    d = new Dialog(getActivity());
    d.setContentView(R.layout.dialog_detail_station);
    final Station station = gson.fromJson(marker.getTitle(), Station.class);
    TextView nameTextView = (TextView) d.findViewById(R.id.nameTextView);
    TextView streetTextView = (TextView) d.findViewById(R.id.streetTextView);
    PieChart mChart = (PieChart) d.findViewById(R.id.chart);
    configureFavButton(station);
    ImageButton walkButton = (ImageButton) d.findViewById(R.id.walkButton);
    walkButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LocationManager manager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
            if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                Toast.makeText(getActivity(), getString(R.string.activate_gps), Toast.LENGTH_SHORT).show();
            }
            Intent cityMapperIntent = getActivity().getPackageManager().getLaunchIntentForPackage("com.citymapper.app.release");
            if (cityMapperIntent != null) {
                try {
                    String locationUrl = "citymapper://directions?endcoord=" + marker.getPosition().latitude + "," + marker.getPosition().longitude + "&endname=" + URLEncoder.encode(station.getNombre(), "UTF-8") + "&endaddress=" + URLEncoder.encode(station.getAddress(), "UTF-8");
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(locationUrl));
                    getActivity().startActivity(i);
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            } else {
                Uri uri = Uri.parse("google.navigation:q=" + marker.getPosition().latitude + "," + marker.getPosition().longitude + "&mode=w");
                Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
                mapIntent.setPackage("com.google.android.apps.maps");
                startActivity(mapIntent);
            }
        }
    });
    configChart(station, mChart);

    nameTextView.setText(station.getNumberStation() + " " + station.getNombre());
    streetTextView.setText(station.getAddress());


    d.show();
}
 
Example 18
Project: cniao5   File: FriendListPage.java   View Source Code Vote up 4 votes
private void initTitle(RelativeLayout rlTitle, float ratio) {
	tvCancel = new TextView(activity);
	tvCancel.setTextColor(0xff3b3b3b);
	tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvCancel.setGravity(Gravity.CENTER);
	int resId = ResHelper.getStringRes(activity, "ssdk_oks_cancel");
	if (resId > 0) {
		tvCancel.setText(resId);
	}
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvCancel.setPadding(padding, 0, padding, 0);
	RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	rlTitle.addView(tvCancel, lp);
	tvCancel.setOnClickListener(this);

	TextView tvTitle = new TextView(activity);
	tvTitle.setTextColor(0xff3b3b3b);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvTitle.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_contacts");
	if (resId > 0) {
		tvTitle.setText(resId);
	}
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	rlTitle.addView(tvTitle, lp);

	tvConfirm = new TextView(activity);
	tvConfirm.setTextColor(0xffff6d11);
	tvConfirm.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvConfirm.setGravity(Gravity.CENTER);
	resId = ResHelper.getStringRes(activity, "ssdk_oks_confirm");
	if (resId > 0) {
		tvConfirm.setText(resId);
	}
	tvConfirm.setPadding(padding, 0, padding, 0);
	lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlTitle.addView(tvConfirm, lp);
	tvConfirm.setOnClickListener(this);
}
 
Example 19
Project: Huochexing12306   File: EditMonitorAty.java   View Source Code Vote up 4 votes
private void tv(int id, CharSequence cs1){
	TextView tv1 = (TextView) findViewById(id);
	tv1.setText(cs1);
}
 
Example 20
Project: AyyMate-Android-RealtimeChat   File: FriendsFragment.java   View Source Code Vote up 2 votes
public void setDate(String date){

            TextView userStatusView = (TextView) mView.findViewById(R.id.user_single_status);
            userStatusView.setText(date);

        }