在添加内容之前必须先调用RequestFeature,不确定为什么要调用它 [英] RequestFeature must be called before adding content, unsure why it's being called
本文介绍了在添加内容之前必须先调用RequestFeature,不确定为什么要调用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我当前正在尝试使用自定义布局文件"details.xml"弹出一个有关电影的信息的AlertDialog框,我觉得这可能是我针对AlertDialog填充这些字段的方式,但是我不确定如何最好地处理它.
I am currently trying to have an AlertDialog box pop up with information regarding a movie with the custom layout file "details.xml" I feel it may be how I am populating these fields with regards to the AlertDialog, but I am unsure how best to handle it.
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> Parent, View view, int position,
long id) {
// TODO Auto-generated method stub
Movie mTemp = movieArray.get(position);
//Intent intent = new Intent(getApplicationContext(), SingleItemList.class);
AlertDialog.Builder builder = new AlertDialog.Builder(MovieList.this);
builder.setView(getLayoutInflater().inflate(R.layout.details, null));
builder.setTitle("Details");
builder.setNeutralButton("Post to Facebook", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User clicked OK button
}
});
AlertDialog d = builder.create();
if (mTemp != null) {
ImageView image = (ImageView) d.findViewById(R.id.detailIcon);
TextView title = (TextView) d.findViewById(R.id.detailTitle);
TextView year = (TextView) d.findViewById(R.id.detailYear);
TextView rating = (TextView) d.findViewById(R.id.detailRating);
TextView director = (TextView) d.findViewById(R.id.detailDirector);
if (title != null) {
title.setText("Name: " + mTemp.title);
}
if(year != null) {
year.setText("Year: " + mTemp.year);
}
if(rating != null) {
rating.setText("Rating: " + mTemp.rating + "/10");
}
if(director != null) {
director.setText("Director: " + mTemp.director);
}
if(image != null) {
image.setImageBitmap(getBitmap(mTemp.coverURL));
}
}
d.show();
/*
Dialog dialog = new Dialog(MovieList.this);
dialog.setTitle("Details");
dialog.setContentView(R.layout.details);
dialog.show();*/
}
});
推荐答案
您尚未发布LogCat错误,但我认为是您的(mTemp != null)
块引起了麻烦.更改膨胀后的视图,然后将其传递给setView()
.
You haven't posted your LogCat errors but I assume that it is your (mTemp != null)
block that is causing trouble. Alter the inflated View, then pass it to setView()
.
View view = getLayoutInflater().inflate(R.layout.details, null);
if (mTemp != null) {
ImageView image = (ImageView) view.findViewById(R.id.detailIcon);
TextView title = (TextView) view.findViewById(R.id.detailTitle);
...
}
AlertDialog.Builder builder = new AlertDialog.Builder(MovieList.this);
builder.setTitle("Details");
builder.setView(view);
builder.setNeutralButton("Post to Facebook", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User clicked OK button
}
});
AlertDialog d = builder.create();
d.show();
这篇关于在添加内容之前必须先调用RequestFeature,不确定为什么要调用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文