我想改变下toast的背景和文本颜色
用了下面的方法:
LayoutInflater infator = getLayoutInflater();
View layout =infator.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toast_layout));
TextView toastText = (TextView) findViewById(R.id.toasttext);
toastText.setBackgroundColor(Color.YELLOW);
toastText.setText(
"uei:"
+o.getUei());
Toast toast =
new
Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
这个代码是我的listview的OnItemClickListener的,但是app由于空指针异常被强制关闭了
这是onclick listener上面的代码:
publi
c
void
onCreate(
final
Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.alarms);
m_alarmAdapter =
new
AlarmAdapter(
this
, R.layout.severity_item, m_alarms);
setListAdapter(m_alarmAdapter);
ListView lv = getListView();
lv.setOnItemClickListener(
new
OnItemClickListener() {
public
void
onItemClick(
final
AdapterView<?> parent,
final
View view,
final
int
position,
final
long
id) {
Log.d(TAG,
"clicked: "
+ view);
final
Alarm o = m_alarmAdapter.getItem(position);
LayoutInflater infator = getLayoutInflater();