我正在尝试将具有DashboardActivityNew的图像和文本的json数据解析到recyclerView,我从json获得了唯一的问题图像。我正在使用毕加索。
RecyclerView recyclerView;
GridLayoutManager gridLayoutManager;
ProgressBar progressBarnewdash;
CustomAdapterDashboard adapterDashboard;
String url5 = "http://support.deverp.com/dms/dms_menu.aspx";
List<DataModelNew> list;
private static final String TAG = DashboardActivityNew.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_dashboard_new);
recyclerView = findViewById(R.id.rvdashboad);
progressBarnewdash = findViewById(R.id.pbnew1);
list = new ArrayList<>();
GridLayoutManager layoutManager = new GridLayoutManager(DashboardActivityNew.this, 3);
loaddata();
adapterDashboard = new CustomAdapterDashboard(DashboardActivityNew.this, list);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setAdapter(adapterDashboard);
adapterDashboard.notifyDataSetChanged();
}
这是json呼叫
JSONArray jsonArray = response.getJSONArray("menu");
for (int i = 0; i < jsonArray.length(); i++) {
DataModelNew dataModelNew = new DataModelNew();
JSONObject count = jsonArray.getJSONObject(i);
Log.e("count", count.getString("menuimage"));
dataModelNew.setMenuhead(count.getString("menuhead"));
dataModelNew.setMenuimage(count.getString("menuimage"));
dataModelNew.setMenutitle(count.getString("menutitle"));
list.add(dataModelNew);
adapterDashboard.notifyDataSetChanged();
这是我的视图所有者
@Override
public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, final int i) {
myViewHolder.textView1title.setText(list.get(i).getMenutitle());
Log.e("imageholder>>>", list.get(i).getMenuimage() + "");
Picasso.get().load(list.get(i).getMenuimage()).placeholder(R.drawable.erp).fit().into(myViewHolder.imageViewurl, new Callback() {
@Override
public void onSuccess() {
Log.e("success>>>", list.get(i).getMenuimage() + "");
}
@Override
public void onError(Exception e) {
Log.e("error>>>", list.get(i).getMenuimage()+e+ "");
}
});
这是项目视图
@Override
public int getItemCount() {
return list.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
TextView textView1title, textViewhead;
ImageView imageViewurl;
CardView cardViewdash;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
context = itemView.getContext();
textView1title = itemView.findViewById(R.id.tvdash);
textViewhead = itemView.findViewById(R.id.toolbar_title);
cardViewdash = itemView.findViewById(R.id.cardnew);
imageViewurl = (ImageView) itemView.findViewById(R.id.ivdash);
这是日志
我正在同时获取和设置图像,但仪表板中没有加载图像,也没有加载图像但没有显示图像。
这是我的物品布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/cardnew"
android:layout_width="@dimen/_85sdp"
android:layout_height="@dimen/_76sdp"
android:layout_margin="5dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_dashboard"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/ivdash"
android:layout_width="@dimen/_45sdp"
android:layout_height="@dimen/_45sdp"
android:background="@color/colorwhite"
android:padding="10dp"
android:scaleType="fitXY"
android:src="@drawable/erp"/>
<TextView
android:id="@+id/tvdash"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:ellipsize="marquee"
android:freezesText="true"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Quatation Report"
android:textColor="@color/colorwhite"
android:textSize="@dimen/_10sdp"
android:textStyle="bold" />
</LinearLayout>
</android.support.v7.widget.CardView>