本文整理匯總了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));
}
}
}