本文整理汇总了Java中android.widget.Toast.getView方法的典型用法代码示例。如果您正苦于以下问题:Java Toast.getView方法的具体用法?Java Toast.getView怎么用?Java Toast.getView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Toast
的用法示例。
在下文中一共展示了Toast.getView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showToast
import android.widget.Toast; //导入方法依赖的package包/类
/**
* {@link #tintDrawable(Drawable, ColorStateList)}
* @param content content to show
* @param longTime short or long
* @param context context
* @param textColor toast text color
* @param toastBackgroundColor toast background color
*/
public static void showToast(@NonNull Context context, String content, boolean longTime,@ColorInt int toastBackgroundColor ,@ColorInt
int textColor) {
int type = longTime ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, content, type);
View toastView = toast.getView();
TextView textView = (TextView) toastView.findViewById(android.R.id.message);
if (toastBackgroundColor != 0){
Drawable toastBackgroundDrawable = tintDrawable(toastView.getBackground(), ColorStateList.valueOf(toastBackgroundColor));
toastView.setBackgroundDrawable(toastBackgroundDrawable);
}
if (textColor!=0){
textView.setTextColor(textColor);
}
toast.setView(toastView);
toast.setText(content);
toast.show();
}
示例2: b
import android.widget.Toast; //导入方法依赖的package包/类
private void b(String str, int i) {
Toast makeText = Toast.makeText(this, str, 1);
LinearLayout linearLayout = (LinearLayout) makeText.getView();
((TextView) linearLayout.getChildAt(0)).setPadding(8, 0, 0, 0);
View imageView = new ImageView(this);
imageView.setLayoutParams(new LinearLayout.LayoutParams(a.a(this, 16.0f), a.a(this, 16.0f)));
if (i == 0) {
imageView.setImageDrawable(b("com.tencent.plus.ic_success.png"));
} else {
imageView.setImageDrawable(b("com.tencent.plus.ic_error.png"));
}
linearLayout.addView(imageView, 0);
linearLayout.setOrientation(0);
linearLayout.setGravity(17);
makeText.setView(linearLayout);
makeText.setGravity(17, 0, 0);
makeText.show();
}
示例3: playByPlaylistId
import android.widget.Toast; //导入方法依赖的package包/类
public void playByPlaylistId(String str,int No){
int count = playlistHandler.getPlaylistLength(Ui.ef.getBaseContext().getContentResolver(),No);
if(count == 0 || count == -1){
Toast toast = Toast.makeText(Gh.getBaseContext(), "Playlist is Empty.", Toast.LENGTH_SHORT);
View view = toast.getView();
view.setBackgroundColor(0xFFD35D69);
toast.show();
return;
}
resetDefault();
list = playlistHandler.getPlaylistByIds(Gh.getContentResolver(),Integer.parseInt(str));
if(list != null && list.size() != 0){
PID = -1;
if(list != null && list.size() > 0){
AID = Integer.parseInt( list.get(0)[1]) ;
} else {
AID = -1;
}
}
playlist.listName = playlistHandler.getPlaylistNameById(Gh.getContentResolver(),Integer.parseInt(str));
playlist.id = Integer.parseInt(str);
playlist.save(list, playlist.listName);
songPrepared = false;
playByNumber(No);
mEvent.trigger(playerEvents.PLAYLIST_CHANGED);
}
示例4: getTextView
import android.widget.Toast; //导入方法依赖的package包/类
private static TextView getTextView(Toast toast) {
LinearLayout layout = (LinearLayout) toast.getView();
TextView tv = (TextView) layout.getChildAt(0);
return tv;
}