gpt4 book ai didi

java - Android Studio : W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED

转载 作者:行者123 更新时间:2023-12-03 02:22:06 26 4
gpt4 key购买 nike

我正在尝试制作电影列表,但它只显示带有应用程序名称的白屏。显然,我有一个与此非常相似的程序,并且运行得很好。这是我运行程序时得到的结果。

W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...

我发现有人说如果xml代码有错误就会出现这个错误,但我仍然会把我的java代码也放上。

public class MainActivity extends AppCompatActivity {

private ListView mListView;
private Context mContext;
ArrayList<Movie> movieList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = this;
final ArrayList<Movie> movieList = Movie.getMoviesFromFile("movies.json", this);
MovieAdapter adapter = new MovieAdapter(this, movieList);

mListView = findViewById(R.id.movie_list_view);
mListView.setAdapter(adapter);

mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Movie selectedMovie = movieList.get(i);

Intent detailIntent = new Intent(mContext, MovieDetailActivity.class);
detailIntent.putExtra("title", selectedMovie.title);
detailIntent.putExtra("description", selectedMovie.description);
detailIntent.putExtra("poster", selectedMovie.poster);

startActivity(detailIntent);
}
});
}

以下是我的适配器。

public class MovieAdapter extends BaseAdapter{
private Context mContext;
private ArrayList<Movie> mMovieList;
private LayoutInflater mInflater;

public MovieAdapter(Context mContext, ArrayList<Movie> mMovieList){
this.mContext = mContext;
this.mMovieList = mMovieList;
mInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount(){return mMovieList.size();}
@Override
public Object getItem(int pos){return mMovieList.get(pos);}
@Override
public long getItemId(int pos){return pos;}
@Override
public View getView(int pos, View convertView, ViewGroup parent){
ViewHolder holder;

if(convertView == null){
convertView = mInflater.inflate(R.layout.list_item_movie, parent, false);
holder = new ViewHolder();
holder.titleTextView = convertView.findViewById(R.id.title);
holder.charactersTextView = convertView.findViewById(R.id.main_characters);
holder.descriptionTextView = convertView.findViewById(R.id.description);
holder.thumbnailImageView = convertView.findViewById(R.id.poster);

convertView.setTag(holder);
} else{
holder = (ViewHolder)convertView.getTag();
}

TextView titleTextView = holder.titleTextView;
TextView descriptionTextView = holder.descriptionTextView;
TextView charactersTextView = holder.charactersTextView;
ImageView thumbnailImageView = holder.thumbnailImageView;
Movie movie = (Movie)getItem(pos);

titleTextView.setText(movie.title);
titleTextView.setTextSize(20);

charactersTextView.setText(movie.main_characters);
charactersTextView.setTextSize(13);

descriptionTextView.setText(movie.description);
descriptionTextView.setTextSize(9);

Picasso.with(mContext).load(movie.poster).into(thumbnailImageView);
return convertView;
}

private static class ViewHolder{
public TextView titleTextView;
public TextView descriptionTextView;
public ImageView thumbnailImageView;
public TextView charactersTextView;
}

}

以下是xml代码。

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.user.junepyolee_miniapp1.MainActivity">

<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/movie_list_view" />

list_item_movie.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/poster"
android:layout_width="90dp"
android:layout_height="140dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="4dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:layout_centerVertical="true"
android:scaleType="fitCenter"
android:contentDescription="This is a thumbnail"
app:srcCompat="@mipmap/ic_launcher" />

<RelativeLayout
android:id="@+id/movie_list_text_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/poster"
android:layout_alignParentTop="false"
android:layout_toRightOf="@+id/poster">

<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:text="Title"
android:textSize="20sp" />

<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:maxLines="3"
android:text="description"
android:textSize="9sp" />

<TextView
android:id="@+id/main_characters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/description"
android:layout_below="@+id/description"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:text="characters max 3 people"
android:textSize="13sp" />

<TextView
android:id="@+id/hasSeen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/main_characters"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:text="has seen?"
android:textSize="11sp" />

</RelativeLayout>

有人能解决这个问题吗?

最佳答案

这只是一个警告,因为它在没有配置选项的情况下重试,而没有(我从您的评论中假设)后续错误,所以这不是问题的根源。

这不是一个坏的猜测,因为这是一个与 OpenGL 相关的类(android/opengl/EGL14),但这不是问题的根源。

您可以在 https://www.khronos.org/egl 阅读有关 EGL 的更多信息。 .

关于java - Android Studio : W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48858307/

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