gpt4 book ai didi

android - RequestFeature 必须在添加内容之前调用,不确定为什么要调用它

转载 作者:行者123 更新时间:2023-11-30 03:54:26 25 4
gpt4 key购买 nike

我目前正在尝试弹出一个 AlertDialog 框,其中包含有关具有自定义布局文件“details.xml”的电影的信息我觉得这可能是我填充这些字段的方式,但我不确定如何最好地处理它。

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) block 导致了问题。更改膨胀的 View ,然后将其传递给 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();

关于android - RequestFeature 必须在添加内容之前调用,不确定为什么要调用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13575750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com