本文整理汇总了Java中android.widget.TextView.post方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.post方法的具体用法?Java TextView.post怎么用?Java TextView.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.post方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initText
import android.widget.TextView; //导入方法依赖的package包/类
private void initText(String summary) {
final TextView tvSummary = getSelfView().getBinding().tvSummary;
final ImageView ivToggle = getSelfView().getBinding().ivToggle;
tvSummary.setVisibility(View.INVISIBLE);
tvSummary.setText(summary);
tvSummary.post(new Runnable() {
@Override
public void run() {
fullHeight = tvSummary.getHeight();
tvSummary.setHeight(tvSummary.getLineHeight() * maxLine);
ivToggle.setVisibility(tvSummary.getLineCount() > maxLine ? View.VISIBLE : View.GONE);
folded = tvSummary.getLineCount() > maxLine;
tvSummary.setVisibility(View.VISIBLE);
}
});
ivToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playAnimation(tvSummary, ivToggle);
}
});
}
示例2: onViewAttached
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onViewAttached(View view) {
if (!hasAttached) {
final TextView tvSummary = getSelfView().getBinding().tvSummary;
final ImageView ivToggle = getSelfView().getBinding().ivToggle;
tvSummary.setText(summary);
tvSummary.post(new Runnable() {
@Override
public void run() {
fullHeight = tvSummary.getHeight();
tvSummary.setHeight(tvSummary.getLineHeight() * maxLine);
ivToggle.setVisibility(tvSummary.getLineCount() > maxLine ? View.VISIBLE : View.GONE);
folded = tvSummary.getLineCount() > maxLine;
}
});
ivToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playAnimation(tvSummary, ivToggle);
}
});
hasAttached = true;
}
}
示例3: done
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void done(Object from) {
if (from instanceof Integer) {
int loadedCount = (int) from;
if (loadedCount >= count) {
state = RichState.loaded;
if (config.cacheType >= CacheType.LAYOUT) {
SpannableStringBuilder ssb = richText.get();
if (ssb != null) {
RichTextPool.getPool().cache(config.source, ssb);
}
}
if (config.callback != null) {
TextView textView = textViewSoftReference.get();
if (textView != null) {
textView.post(new Runnable() {
@Override
public void run() {
config.callback.done(true);
}
});
}
}
}
}
}
示例4: initToast
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 返回一个唯一的toast
*
* @param content the content
* @param text the text
* @return the toast
*/
private static Toast initToast(Context content, CharSequence text) {
if (toast == null) {
synchronized (T.class) {
if (toast == null) {
toast = Toast.makeText(content, text, Toast.LENGTH_SHORT);
makeToastFullscreen(content, toast);
toast.setView(createToastView(content));
}
}
}
//toast.setGravity(T_GRAVITY, 0, content.getResources().getDisplayMetrics().heightPixels);
toast.setGravity(T_GRAVITY, 0, T_OFFSET_Y);
final View rootView = toast.getView().findViewWithTag("root");
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
TextView textView = (TextView) toast.getView().findViewWithTag("text");
textView.setText(text);
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - lastTime < 2000) {
textView.post(new Runnable() {
@Override
public void run() {
// ViewCompat.setScaleY(rootView, 0);
if (rootView != null) {
ViewCompat.setTranslationY(rootView, rootView.getMeasuredHeight());
ViewCompat.animate(rootView)
.setInterpolator(new LinearInterpolator())
.translationY(0)/*.scaleY(1)*/
.setDuration(300)
.start();
}
}
});
}
lastTime = currentTimeMillis;
return toast;
}
示例5: initViews
import android.widget.TextView; //导入方法依赖的package包/类
private void initViews(){
mContentView = LayoutInflater.from(mContext)
.inflate(R.layout.item_wave_loading_view, mViewGroup, false);
mWaveLoadingView = (WaveLoadingView) mContentView.findViewById(R.id.wave_loading_view);
mWaveLoadingView.post(new Runnable() {
@Override
public void run() {
mWaveLoadingView.setWaveColor(mBookshelf.getColor());
}
});
mRedPicker = (SeekBar) mContentView.findViewById(R.id.red_picker);
mGreenPicker = (SeekBar) mContentView.findViewById(R.id.green_picker);
mBluePicker = (SeekBar) mContentView.findViewById(R.id.blue_picker);
mAmpPicker = (SeekBar) mContentView.findViewById(R.id.amp_picker);
mWavePicker = (SeekBar) mContentView.findViewById(R.id.wave_picker);
mCurrentPage = (EditText) mContentView.findViewById(R.id.edit_current_page);
mTotalPages = (TextView) mContentView.findViewById(R.id.text_total_page);
mConfirmButton = (Button) mContentView.findViewById(R.id.button_confirm);
//mCancelButton = (Button) mContentView.findViewById(R.id.button_cancel);
mRedPicker.post(new Runnable() {
@Override
public void run() {
mRedPicker.setProgress( (int)((mBookshelf.getRed() / 255.0f) * 100));
}
});
mGreenPicker.post(new Runnable() {
@Override
public void run() {
mGreenPicker.setProgress((int)((mBookshelf.getGreen() / 255.0f) * 100));
}
});
mBluePicker.post(new Runnable() {
@Override
public void run() {
mBluePicker.setProgress((int)((mBookshelf.getBlue() / 255.0f) * 100));
}
});
mAmpPicker.post(new Runnable() {
@Override
public void run() {
//范围是0~1
mAmpPicker.setProgress((int) (mBookshelf.getAmpratio() * 100));
}
});
mWavePicker.post(new Runnable() {
@Override
public void run() {
mWavePicker.setProgress((int) (mBookshelf.getWaveratio() * 100));
}
});
mCurrentPage.post(new Runnable() {
@Override
public void run() {
mCurrentPage.setText(""+mBookshelf.getCurrentpage());
}
});
mTotalPages.post(new Runnable() {
@Override
public void run() {
mTotalPages.setText("of "+mBookshelf.getTotalpage());
}
});
//mWaveLoadingView.setProgress(mBookshelf.getProgress());
Log.e("此时progress是",mBookshelf.getProgress()+"");
mWaveLoadingView.setTitletext(((int)(mBookshelf.getProgress() * 100)) + "" + " %");
}
示例6: generateAndSet
import android.widget.TextView; //导入方法依赖的package包/类
protected void generateAndSet() {
final TextView textView = textViewSoftReference.get();
if (textView != null) {
textView.post(new Runnable() {
@Override
public void run() {
asyncGenerate(textView);
}
});
}
}
示例7: resetText
import android.widget.TextView; //导入方法依赖的package包/类
private void resetText() {
final TextView tv = textViewWeakReference.get();
if (tv != null) {
tv.post(new Runnable() {
@Override
public void run() {
CharSequence cs = tv.getText();
tv.setText(cs);
}
});
}
}
示例8: onBindViewHolder
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(UpdateViewHolder holder, int position) {
final View itemView = holder.itemView;
Update update = updates[position];
// set text
final TextView tvText = itemView.findViewById(R.id.tv_updatecard_text);
tvText.setText(update.getText());
// messy hack that android forces me to use
// i can't get the line count without queuing a runnable, because it isn't known yet
// and will only be known once the layout is drawn
// queuing a runnable will make sure that it's called after drawing
tvText.post(() -> {
// if line count is more than the max
if (tvText.getLineCount() > 3) {
// set expand view to be visible
View viewExpand = itemView.findViewById(R.id.view_updatecard_expand);
viewExpand.setVisibility(View.VISIBLE);
}
});
// set class
TextView tvClass = itemView.findViewById(R.id.tv_updatecard_class);
if (update.getAffected().isGlobal()) {
// tells user it's a global update
tvClass.setText(R.string.global_update);
} else {
// appends all classes to the class textview
if (update.getAffected() instanceof ClassesAffected) {
// get user's class
String userClass = PreferenceUtil.getClassPreference(holder.itemView.getContext());
// get the affected instance
ClassesAffected affected = (ClassesAffected) update.getAffected();
// set class textview to show affected classes, with user's class first
tvClass.setText(UpdateHelper.formatClassString(affected.getClassesAffected(), userClass));
}
}
}