android.widget.TextView#setText ( )源码实例Demo

下面列出了android.widget.TextView#setText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: StackCardsView   文件: ImageCardItem.java
@Override
public View getView(View convertView, ViewGroup parent) {
    convertView = View.inflate(mContext,R.layout.item_imagecard,null);
    ImageView imageView = Utils.findViewById(convertView,R.id.image);
    TextView labelview = Utils.findViewById(convertView,R.id.label);
    ImageView left = Utils.findViewById(convertView,R.id.left);
    ImageView right = Utils.findViewById(convertView,R.id.right);
    ImageView up = Utils.findViewById(convertView,R.id.up);
    ImageView down = Utils.findViewById(convertView,R.id.down);
    ViewHolder vh = new ViewHolder();
    vh.left = left;
    vh.right = right;
    vh.up = up;
    vh.down = down;
    convertView.setTag(vh);
    Glide.with(mContext)
            .load(url)
            .placeholder(R.drawable.img_dft)
            .centerCrop()
            .crossFade()
            .into(imageView);
    labelview.setText(label);
    return convertView;
}
 
private void createTimer(final long milliseconds) {
    // Create the game timer, which counts down to the end of the level
    // and shows the "retry" button.
    if (countDownTimer != null) {
        countDownTimer.cancel();
    }

    final TextView textView = findViewById(R.id.timer);

    countDownTimer = new CountDownTimer(milliseconds, 50) {
        @Override
        public void onTick(long millisUnitFinished) {
            timerMilliseconds = millisUnitFinished;
            textView.setText("seconds remaining: " + ((millisUnitFinished / 1000) + 1));
        }

        @Override
        public void onFinish() {
            gameIsInProgress = false;
            textView.setText("done!");
            retryButton.setVisibility(View.VISIBLE);
        }
    };
}
 
源代码3 项目: PLDroidMediaStreaming   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TextView versionInfo = (TextView) findViewById(R.id.version_info);
    mInputTextTV = (TextView) findViewById(R.id.input_url);
    mInputTypeSpinner = (Spinner) findViewById(R.id.stream_input_types);
    mStreamTypeSpinner = (Spinner) findViewById(R.id.stream_types);
    mDebugModeCheckBox = (CheckBox) findViewById(R.id.debug_mode);
    mQuicPushButton = (RadioButton) findViewById(R.id.transfer_quic);

    mInputTextTV.setText(Cache.retrieveURL(this));

    FragmentManager fragmentManager = getSupportFragmentManager();
    mEncodingConfigFragment = (EncodingConfigFragment) fragmentManager.findFragmentById(R.id.encoding_config_fragment);
    mCameraConfigFragment = (CameraConfigFragment) fragmentManager.findFragmentById(R.id.camera_config_fragment);

    versionInfo.setText("versionName: " + BuildConfig.VERSION_NAME + " versionCode: " + BuildConfig.VERSION_CODE);
    initInputTypeSpinner();
    initStreamTypeSpinner();
}
 
@Override
public View getRefreshHeaderView() {
    if (mRefreshHeaderView == null) {
        mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_normal, null);
        mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT);
        if (mRefreshViewBackgroundColorRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes);
        }
        if (mRefreshViewBackgroundDrawableRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes);
        }
        mHeaderStatusTv = (TextView) mRefreshHeaderView.findViewById(R.id.tv_normal_refresh_header_status);
        mHeaderArrowIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_arrow);
        mHeaderChrysanthemumIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_chrysanthemum);
        mHeaderChrysanthemumAd = (AnimationDrawable) mHeaderChrysanthemumIv.getDrawable();
        mHeaderStatusTv.setText(mPullDownRefreshText);
    }
    return mRefreshHeaderView;
}
 
源代码5 项目: BackPackTrackII   文件: StepCountAdapter.java
@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    // Get values
    long time = cursor.getLong(colTime);
    int count = cursor.getInt(colCount);

    // Get views
    TextView tvTime = (TextView) view.findViewById(R.id.tvTime);
    TextView tvCount = (TextView) view.findViewById(R.id.tvCount);
    TextView tvDistance = (TextView) view.findViewById(R.id.tvDistance);
    TextView tvCalories = (TextView) view.findViewById(R.id.tvCalories);

    // Calculations
    float distance = count * stepsize / 100f;
    float calories = (distance / 1000f / 1.609344f) * (weight / 0.45359237f) * 0.3f;
    // http://www.runnersworld.com/weight-loss/how-many-calories-are-you-really-burning

    // Set values
    float zone = (time % (24 * 3600 * 1000L)) / (float) (3600 * 1000);
    zone = (zone <= 12 ? 0 : 24) - zone;
    tvTime.setText(SDF.format(time + 12 * 3600 * 1000L) + ZF.format(zone));
    tvCount.setText(Long.toString(count));
    tvDistance.setText(Long.toString(Math.round(distance)));
    tvCalories.setText(Long.toString(Math.round(calories)));
}
 
源代码6 项目: hugo   文件: HugoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  TextView tv = new TextView(this);
  tv.setText("Check logcat!");
  setContentView(tv);

  printArgs("The", "Quick", "Brown", "Fox");

  Log.i("Fibonacci", "fibonacci's 4th number is " + fibonacci(4));

  Greeter greeter = new Greeter("Jake");
  Log.d("Greeting", greeter.sayHello());

  Charmer charmer = new Charmer("Jake");
  Log.d("Charming", charmer.askHowAreYou());

  startSleepyThread();
}
 
源代码7 项目: HomeApplianceMall   文件: SubmitOrderActivity.java
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = LayoutInflater.from(context).inflate(R.layout.item_a_order_submit,null);
    ImageView imageView = (ImageView) v.findViewById(R.id.imageView_i_a_order_img);
    TextView textName = (TextView) v.findViewById(R.id.textView_i_a_order_submit_name);
    TextView textNumber = (TextView) v.findViewById(R.id.textView_i_a_order_submit_number);
    TextView textPrice = (TextView) v.findViewById(R.id.textView_i_a_order_submit_price);
    imageView.setImageResource((int)list.get(position).get("img"));
    textName.setText((String)list.get(position).get("name"));
    textNumber.setText((String)list.get(position).get("number"));
    textPrice.setText((String)list.get(position).get("price"));
    if(!list.get(position).containsKey("imgPath") || list.get(position).get("imgPath")==null){
        imageView.setImageResource(R.drawable.wait);
    }else{
        BitmapFactory.Options options=new BitmapFactory.Options();
        options.inSampleSize = 3;
        imageView.setImageBitmap(BitmapFactory.decodeFile((String)list.get(position).get("imgPath"),options));
    }
    return v;
}
 
源代码8 项目: EasyNLU   文件: BindingAdapters.java
@BindingAdapter("textRepeat")
public static void textRepeat(TextView view, long repeatDuration){
    if(repeatDuration != -1){
        final long[] duration = {0};
        final String[] unit = {""};

        zip(KEYS_MUL, KEYS_TIME)
            .forEach((mul, time) ->{
                if(repeatDuration % mul == 0){
                    duration[0] = repeatDuration / mul;
                    unit[0] = time;
                    return false;
                }

                return true;
            });

        if(duration[0] > 0){
            if(duration[0] == 1)
                view.setText(String.format("Every %s", unit[0]));
            else
                view.setText(String.format("Every %d %ss", (int)duration[0], unit[0]));
        }
    }
}
 
源代码9 项目: BLE   文件: DeviceDetailActivity.java
/**
 * 追加信息头
 *
 * @param adapter
 * @param title
 */
private void appendHeader(final MergeAdapter adapter, final String title) {
    final LinearLayout lt = (LinearLayout) getLayoutInflater().inflate(R.layout.list_item_view_header, null);
    final TextView tvTitle = (TextView) lt.findViewById(R.id.title);
    tvTitle.setText(title);

    adapter.addView(lt);
}
 
源代码10 项目: CrazyDaily   文件: SatelliteMenuView.java
public void setImgText(ImgTextEntity entity) {
    final Context context = getContext();
    TextView textView = new TextView(context);
    @SuppressLint("RestrictedApi")
    Typeface typeface = TypefaceCompat.createFromResourcesFontFile(context, getResources(), R.font.crazydailyicon, "", 0);
    textView.setTypeface(typeface);
    textView.setText(entity.text);
    textView.setTextSize(SIZE * BUTTON_RATIO * TEXT_RATIO);
    OvalShape shape = new OvalShape();
    PaintDrawable shapeDrawable = new PaintDrawable(entity.color);
    shapeDrawable.setShape(shape);
    textView.setTextColor(Color.WHITE);
    textView.setBackground(shapeDrawable);
    textView.setGravity(Gravity.CENTER);
    final int size = (int) (SIZE * BUTTON_RATIO);
    LayoutParams params = new LayoutParams(size, size);
    params.gravity = Gravity.END | Gravity.BOTTOM;
    addView(textView, params);
    mButtonView = textView;
    mButtonView.setOnClickListener(v -> {
        if (isOpen) {
            close();
        } else {
            show();
        }
    });
}
 
源代码11 项目: sealrtc-android   文件: VerifyActivity.java
private void initView() {
    btn_login = (Button) findViewById(R.id.btn_login);
    reg_getcode = (Button) findViewById(R.id.reg_getcode);
    btn_login.setOnClickListener(onClickListener);
    btn_login.setClickable(false);

    reg_getcode.setOnClickListener(onClickListener);
    edit_phone = (EditText) findViewById(R.id.edit_phone);
    String phone = SessionManager.getInstance().getString(UserUtils.PHONE);
    if (!TextUtils.isEmpty(phone)) {
        edit_phone.setText(phone);
        reg_getcode.setClickable(true);
        reg_getcode.setBackgroundDrawable(
            getResources().getDrawable(R.drawable.rs_select_btn_blue));
    }
    tv_tips = (TextView) findViewById(R.id.tv_tips);
    edit_verificationCode = (EditText) findViewById(R.id.edit_verificationCode);
    versionCodeView = (TextView) findViewById(R.id.main_page_version_code);
    versionCodeView.setText(
        getResources().getString(R.string.blink_description_version)
            + BuildConfig.VERSION_NAME
            + (BuildConfig.DEBUG ? "_Debug" : ""));
    versionCodeView.setTextColor(getResources().getColor(R.color.blink_text_green));
    mTvRegion = (TextView) findViewById(R.id.tv_region);
    mTvCountry = (TextView) findViewById(R.id.tv_country);
    mTvCountry.setOnClickListener(onClickListener);
    updateCountry();
    img_logo = (ImageView) findViewById(R.id.img_logo);
    if (img_logo != null) {
        if (ServerUtils.usePrivateCloud()) {
            img_logo.setImageResource(R.drawable.ic_launcher_privatecloud);
        } else {
            img_logo.setImageResource(R.drawable.ic_launcher);
        }
    }
}
 
源代码12 项目: batteryhub   文件: CustomExpandableListAdapter.java
@Override
public View getChildView(int listPosition, final int expandedListPosition,
                         boolean isLastChild, View convertView, ViewGroup parent) {
    final String expandedListText = (String) getChild(listPosition, expandedListPosition);
    if (convertView == null) {
        convertView = mLayoutInflater.inflate(R.layout.sensors_list_item, null);
    }
    TextView expandedListTextView = (TextView) convertView
            .findViewById(R.id.expandedListItem);
    expandedListTextView.setText(expandedListText);
    return convertView;
}
 
源代码13 项目: Collection-Android   文件: OutSideFrameTabLayout.java
private void updateTabStates() {

        for (int i = 0; i < mTabCount; i++) {
            View v = mTabsContainer.getChildAt(i);
            TextView tv_tab_title = v.findViewById(R.id.tv_tab_title);
            if (tv_tab_title != null) {
                tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnSelectColor);
                tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
                tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
                if (mTextAllCaps) {
                    tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
                }
            }
        }
    }
 
源代码14 项目: SimpleProject   文件: TabLayout.java
public void setItemData(int[] textColor, String[] tabText, int[] normalIconIds, int[] selectedIconIds) {
	if (tabText == null || normalIconIds == null || selectedIconIds == null) {
		throw new NullPointerException("tabText or selectedIconId or unselectedIconId is null");
	} else if (tabText.length == 0 || tabText.length != normalIconIds.length
			|| selectedIconIds.length != normalIconIds.length) {
		throw new NullPointerException("tabText, selectedIconId and unselectedIconId should has same size");
	}

	LayoutParams params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
	params.weight = 1;
	params.gravity = Gravity.CENTER;
	ColorStateList colorState = new ColorStateList(new int[][]{
			new int[]{android.R.attr.state_selected},
			new int[]{}
	}, textColor);

	LinearLayout.LayoutParams iconParams = null;
	if (mIconSize != 0) {
		iconParams = new LinearLayout.LayoutParams(mIconSize, mIconSize);
		iconParams.gravity = Gravity.CENTER;
	}
	for (int i = 0; i < tabText.length; i++) {
		View childView = View.inflate(getContext(), R.layout.bl_item_tab_layout, null);
		TextView textView = childView.findViewById(R.id.bl_tab_text);
		ImageView tabIcon = childView.findViewById(R.id.bl_tab_icon);
		textView.setText(tabText[i]);
		textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
		textView.setTextColor(colorState);
		if (mMiddleGap != 0) {
			textView.setPadding(0, mMiddleGap, 0, 0);
		}
		if (iconParams != null) {
			tabIcon.setLayoutParams(iconParams);
		}
		ViewBgUtil.setTextColor(textView, android.R.attr.state_selected, textColor);
		ViewBgUtil.setSelectorBg(tabIcon, android.R.attr.state_selected, new int[]{
				normalIconIds[i], selectedIconIds[i]});
		addView(childView, params);
	}
}
 
源代码15 项目: BooheeRuler   文件: KgNumberLayout.java
private void init(Context context){
    LayoutInflater.from(context).inflate(R.layout.layout_kg_number,this);
    tv_scale = (TextView) findViewById(R.id.tv_scale);
    tv_kg = (TextView) findViewById(R.id.tv_kg);

    tv_scale.setTextSize(TypedValue.COMPLEX_UNIT_PX,mScaleTextSize);
    tv_scale.setTextColor(mScaleTextColor);

    tv_kg.setTextSize(TypedValue.COMPLEX_UNIT_PX,mKgTextSize);
    tv_kg.setTextColor(mKgTextColor);
    tv_kg.setText(mUnitText);
}
 
源代码16 项目: githot   文件: TrendingReposTimeSpanAdapter.java
@Override
public View getView(int position, View view, ViewGroup parent) {
    if (view == null || !view.getTag().toString().equals("DROPDOWN")) {
        view = ((Activity) mContext).getLayoutInflater().inflate(R.layout.trending_repos_timespan_list_item_actionbar, parent, false);
        view.setTag("DROPDOWN");
    }

    TextView textView = (TextView) view.findViewById(android.R.id.text1);
    textView.setText(getItem(position).toString());

    return view;
}
 
源代码17 项目: TraceByAmap   文件: WeatherSearchActivity.java
private void init() {
    TextView city = (TextView) findViewById(R.id.city);
    city.setText(cityname);
    forecasttv = (TextView) findViewById(R.id.forecast);
    reporttime1 = (TextView) findViewById(R.id.reporttime1);
    reporttime2 = (TextView) findViewById(R.id.reporttime2);
    weather = (TextView) findViewById(R.id.weather);
    Temperature = (TextView) findViewById(R.id.temp);
    wind = (TextView) findViewById(R.id.wind);
    humidity = (TextView) findViewById(R.id.humidity);
}
 
源代码18 项目: FastAndroid   文件: ImageLoaderMainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_loader_main);

    // Example of a call to a native method
    TextView tv = (TextView) findViewById(R.id.sample_text);
    tv.setText(stringFromJNI());
}
 
源代码19 项目: MiHomePlus   文件: AppSetting.java
private boolean getSetting() {

        int readSettingTimes = 0;

        SharedPreferences settings = getSharedPreferences(data, 0);
        Hosts = settings.getString(addressField, "");

        if (Hosts.equals("")) {
            tellUser("伺服器不能為空");
            return false;
        }

        getSettingbyServer();

        TextView room = (TextView) findViewById(R.id.roomField);
        TextView devices = (TextView) findViewById(R.id.devicesField);
        room.setText("正在重新同步...");
        devices.setText("正在重新同步...");

        tellUser("正在讀取");

        do {
            readSettingTimes = readSettingTimes + 1;
            SystemClock.sleep(1500);
            if (readSettingTimes >= 3) {
                tellUser("讀取配置超時");
                return false;
            }
        } while (!isSettingReadly);

        Log.i(TAG, "getSettingJSON: " + getSettingJSON);

        try {
            JSONObject settingData = new JSONObject(getSettingJSON);
            settingDevices = settingData.getString("devices");
            settingRoom = settingData.getString("room");

            settings.edit()
                    .putString(settingRoomField, settingRoom)
                    .putString(settingDevicesField, settingDevices)
                    .apply();

            Log.i(TAG, "settingDevices: " + settingDevices);
            Log.i(TAG, "settingRoom: " + settingRoom);


            settings = getSharedPreferences(data, 0);

            room.setText(settings.getString(settingRoomField, "房間名稱"));
            devices.setText(settings.getString(settingDevicesField, "設備列表"));

            tellUser("讀取成功");

            return true;
        } catch (JSONException e) {
            e.printStackTrace();
        }

        tellUser("讀取失敗");
        return false;
    }
 
源代码20 项目: mConference-Framework   文件: Talk.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_talk);

    Toolbar toolbar = (Toolbar) findViewById(R.id.talk_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    final TalkDetails talkDetails = (TalkDetails)getIntent().getSerializableExtra("TalkDetails");
    final Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.abc_ic_ab_back_mtrl_am_alpha);
    upArrow.setColorFilter(ContextCompat.getColor(this, android.R.color.white), PorterDuff.Mode.SRC_ATOP);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(upArrow);

    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.talk_toolbar_layout);
    collapsingToolbarLayout.setTitle(talkDetails.getName());
    collapsingToolbarLayout.setExpandedTitleColor(ContextCompat.getColor(this, android.R.color.white));
    collapsingToolbarLayout.setCollapsedTitleTextColor(ContextCompat.getColor(this, android.R.color.white));

    final ImageView talkImage = (ImageView) findViewById(R.id.talk_collapsible_image);
    TextView talkTime = (TextView) findViewById(R.id.talk_time_detail);
    TextView talkLocation = (TextView) findViewById(R.id.talk_venue_detail);
    TextView talkDesc = (TextView) findViewById(R.id.talk_desc_detail);

    SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm a");
    String talkTimeText = dateFormat.format(talkDetails.getStartTime())
            + " - " + dateFormat.format(talkDetails.getEndTime());
    talkTime.setText(talkTimeText);

    talkLocation.setText(talkDetails.getLocation());
    talkDesc.setText(talkDetails.getDesc());

    Picasso.with(this)
            .load(Uri.parse(talkDetails.getImageURL()))
            .error(R.drawable.placeholder_1)
            .fit().centerCrop().into(talkImage, new com.squareup.picasso.Callback() {
        @Override
        public void onSuccess() {
            applyPalette(talkImage);
        }

        @Override
        public void onError() {
            Log.d("Talk.java", "Error caused by Picasso");
            applyPalette(talkImage);
        }
    });

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.talk_reminder);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_EDIT);
            intent.setType("vnd.android.cursor.item/event");
            intent.putExtra(CalendarContract.Events.TITLE,
                    talkDetails.getName());
            intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
                    talkDetails.getStartTime().getTime());
            intent.putExtra(CalendarContract.Events.EVENT_LOCATION,
                    talkDetails.getLocation());
            intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
                    talkDetails.getEndTime().getTime());
            intent.putExtra(CalendarContract.Events.ALL_DAY, false);
            intent.putExtra(CalendarContract.Events.DESCRIPTION,
                    talkDetails.getShortDesc());
            v.getContext().startActivity(intent);
        }
    });
}
 
 方法所在类
 同类方法