package cn.juzhong.view.widget;
import cn.juzhong.R;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
public class UiToast {
Context mContext;
String str;
int id;
public UiToast(Context context,String string){
mContext = context;
str = string;
}
public UiToast(Context context,int id){
mContext = context;
str = context.getResources().getString(id);
}
public void show(){
Toast toast = new Toast(mContext);
LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.view_toast, null);
TextView text = (TextView) contentView.findViewById(R.id.view_toast_textview);
if(!TextUtils.isEmpty(str)){
text.setText(str);
toast.setView(contentView);
toast.setGravity(Gravity.TOP, Gravity.LEFT, Gravity.TOP + 100);
toast.setDuration(Toast.LENGTH_SHORT);
toast.show();
}
}
public String getStr() {
return str;
}
public void setStr(String str) {
this.str = str;
}
}