public void onBindViewHolder(@NonNull final myViewHolder holder, final int position) {
holder.tvItem.setText(itemList.get(position).getmTitle());
Picasso.get().load(itemList.get(position).geturl()).into(holder.imgFlag);
final ModelClass model= itemList.get(position);
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DataFragment dataFragment= new DataFragment();
((AppCompatActivity)mContext).getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment,dataFragment)
.commit();
Bundle bundle= new Bundle();
bundle.putSerializable("model", model);
dataFragment.setArguments(bundle);
}
});
}
}
答案 0 :(得分:0)
您可以在片段上创建用于更新它的方法,如果该片段已经存在,请使用该方法。
示例:
for index, movies in data.iterrows():
try:
c.execute("INSERT INTO movie VALUES (:budget, :homepage, :id, :original_language, :original_title, :overview, :popularity, :release_date, :revenue, :runtime, :status, :tagline, :title, :vote_average, :vote_count)",
{'budget': movies['budget'], 'homepage': movies['homepage'], 'id': movies['id'], 'original_language': movies['original_language'], 'original_title': movies['original_title'],
'overview': movies['overview'], 'popularity': movies['popularity'], 'release_date': movies['release_date'], 'revenue': movies['revenue'], 'runtime': movies['runtime'],
'status': movies['status'], 'tagline': movies['tagline'],
'title': movies['title'], 'vote_average': movies['vote_average'], 'vote_count': movies['vote_count']})
except sqlite3.IntegrityError as e:
pass # ignore SQLite complaints about UNIQUE primary keys
for movie_genres in data['genres']:
for genres in movie_genres:
try:
c.execute("INSERT INTO genre VALUES (:id, :name)", {'id': genres['id'], 'name': genres['name']})
except sqlite3.IntegrityError as e:
pass # ignore SQLite complaints about UNIQUE primary keys
希望有帮助!