毕业设计做的是一款足球新闻app 用的是android studio 语言是java,数据库用的是bmob,遇到点问题,主页的数据正常的显示了,但是显示显示球队排名的这一页数据不显示了,先贴几张图片,如果不行的话我可以贴源码,求大神帮我看看。
liga
public class LigaCategoryFragment extends Fragment{
private MainActivity mainActivity;
private ListView listView2_category_liga;
private LinearLayout load_layout;
private ArrayList<ClubInfo>clubInfos=new ArrayList<>();
private ClubListItemAdapter clubListItemAdapter;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mainActivity= (MainActivity) getActivity();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_category,null);
listView2_category_liga=view.findViewById(R.id.listView2_category);
load_layout=view.findViewById(R.id.load_layout);
clubListItemAdapter=new ClubListItemAdapter(mainActivity,clubInfos);
listView2_category_liga.setAdapter(clubListItemAdapter);
loadData();
return view;
}
//初始化数据
private void loadData() {
if (clubInfos.size()==0){
load_layout.setVisibility(View.VISIBLE);
listView2_category_liga.setVisibility(View.GONE);
BmobQuery<ClubInfo>query=new BmobQuery<>();
query.setCachePolicy(BmobQuery.CachePolicy.CACHE_ELSE_NETWORK);
query.addWhereEqualTo("categoryId ","5yVY444B");
query.findObjects(mainActivity, new FindListener<ClubInfo>() {
@Override
public void onSuccess(List<ClubInfo> list) {
load_layout.setVisibility(View.GONE);
listView2_category_liga.setVisibility(View.VISIBLE);
clubListItemAdapter.setClubInfos((ArrayList<ClubInfo>) list);
clubListItemAdapter.notifyDataSetChanged();
}
@Override
public void onError(int i, String s) {
load_layout.setVisibility(View.GONE);
listView2_category_liga.setVisibility(View.VISIBLE);
}
});
}
}
}
viewholder
public class ViewHolder {
public static <T extends View>T getView(View view, int id){
SparseArray<View> viewHolder=(SparseArray<View>)view.getTag();
if(viewHolder==null){
viewHolder=new SparseArray<>();
view.setTag(viewHolder);
}
View v = viewHolder.get(id);
if(v==null){
v=view.findViewById(id);
viewHolder.put(id,v);
}
return (T) v;
}
}
clubItemadapter
public class ClubListItemAdapter extends BaseAdapter{
private String path =Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+"/FootballnewStore";
private Context context;
private ArrayList<ClubInfo>clubInfos;
private BitmapUtils bitmapUtils;
public ClubListItemAdapter(Context context, ArrayList<ClubInfo>clubInfos){
this.context=context;
this.clubInfos=clubInfos;
bitmapUtils= new BitmapUtils(context,path);
bitmapUtils.configDefaultBitmapMaxSize(100,100);
}
@Override
public int getCount() {
return clubInfos.size();
}
@Override
public Object getItem(int position) {
return clubInfos.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView==null){
convertView= LayoutInflater.from(context).inflate(R.layout.data_list_item,null);
}
TextView tv_pm=ViewHolder.getView(convertView,R.id.textView_pm);
TextView tv_name=ViewHolder.getView(convertView,R.id.textView1_name);
TextView tv_cc=ViewHolder.getView(convertView,R.id.textView2_cc);
TextView tv_win=ViewHolder.getView(convertView,R.id.textView3_win);
TextView tv_lose=ViewHolder.getView(convertView,R.id.textView6_lose);
TextView tv_pg=ViewHolder.getView(convertView,R.id.textView4_pg);
TextView tv_jf=ViewHolder.getView(convertView,R.id.textView5_jf);
ImageView imageView_cm=ViewHolder.getView(convertView,R.id.imageView_club);
ClubInfo clubInfo=clubInfos.get(position);
tv_pm.setText(clubInfo.getRanking());
tv_name.setText(clubInfo.getClubname());
tv_cc.setText(clubInfo.getChangci());
tv_win.setText(clubInfo.getWin());
tv_lose.setText(clubInfo.getLose());
tv_pg.setText(clubInfo.getPing());
tv_jf.setText(clubInfo.getJifen());
//显示图片
bitmapUtils.display(imageView_cm,clubInfo.getClubimage().getFileUrl(context));
return convertView;
}
public ArrayList<ClubInfo>getClubInfos(){
return clubInfos;
}
public void setClubInfos(ArrayList<ClubInfo> clubInfos) {
this.clubInfos = clubInfos;
}
}
liga
public class LigaCategoryFragment extends Fragment{
private MainActivity mainActivity;
private ListView listView2_category_liga;
private LinearLayout load_layout;
private ArrayList<ClubInfo>clubInfos=new ArrayList<>();
private ClubListItemAdapter clubListItemAdapter;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mainActivity= (MainActivity) getActivity();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_category,null);
listView2_category_liga=view.findViewById(R.id.listView2_category);
load_layout=view.findViewById(R.id.load_layout);
clubListItemAdapter=new ClubListItemAdapter(mainActivity,clubInfos);
listView2_category_liga.setAdapter(clubListItemAdapter);
loadData();
return view;
}
//初始化数据
private void loadData() {
if (clubInfos.size()==0){
load_layout.setVisibility(View.VISIBLE);
listView2_category_liga.setVisibility(View.GONE);
BmobQuery<ClubInfo>query=new BmobQuery<>();
query.setCachePolicy(BmobQuery.CachePolicy.CACHE_ELSE_NETWORK);
query.addWhereEqualTo("categoryId ","5yVY444B");
query.findObjects(mainActivity, new FindListener<ClubInfo>() {
@Override
public void onSuccess(List<ClubInfo> list) {
load_layout.setVisibility(View.GONE);
listView2_category_liga.setVisibility(View.VISIBLE);
clubListItemAdapter.setClubInfos((ArrayList<ClubInfo>) list);
clubListItemAdapter.notifyDataSetChanged();
}
@Override
public void onError(int i, String s) {
load_layout.setVisibility(View.GONE);
listView2_category_liga.setVisibility(View.VISIBLE);
}
});
}
}
}
viewholder
public class ViewHolder {
public static <T extends View>T getView(View view, int id){
SparseArray<View> viewHolder=(SparseArray<View>)view.getTag();
if(viewHolder==null){
viewHolder=new SparseArray<>();
view.setTag(viewHolder);
}
View v = viewHolder.get(id);
if(v==null){
v=view.findViewById(id);
viewHolder.put(id,v);
}
return (T) v;
}
}
clubItemadapter
public class ClubListItemAdapter extends BaseAdapter{
private String path =Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+"/FootballnewStore";
private Context context;
private ArrayList<ClubInfo>clubInfos;
private BitmapUtils bitmapUtils;
public ClubListItemAdapter(Context context, ArrayList<ClubInfo>clubInfos){
this.context=context;
this.clubInfos=clubInfos;
bitmapUtils= new BitmapUtils(context,path);
bitmapUtils.configDefaultBitmapMaxSize(100,100);
}
@Override
public int getCount() {
return clubInfos.size();
}
@Override
public Object getItem(int position) {
return clubInfos.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView==null){
convertView= LayoutInflater.from(context).inflate(R.layout.data_list_item,null);
}
TextView tv_pm=ViewHolder.getView(convertView,R.id.textView_pm);
TextView tv_name=ViewHolder.getView(convertView,R.id.textView1_name);
TextView tv_cc=ViewHolder.getView(convertView,R.id.textView2_cc);
TextView tv_win=ViewHolder.getView(convertView,R.id.textView3_win);
TextView tv_lose=ViewHolder.getView(convertView,R.id.textView6_lose);
TextView tv_pg=ViewHolder.getView(convertView,R.id.textView4_pg);
TextView tv_jf=ViewHolder.getView(convertView,R.id.textView5_jf);
ImageView imageView_cm=ViewHolder.getView(convertView,R.id.imageView_club);
ClubInfo clubInfo=clubInfos.get(position);
tv_pm.setText(clubInfo.getRanking());
tv_name.setText(clubInfo.getClubname());
tv_cc.setText(clubInfo.getChangci());
tv_win.setText(clubInfo.getWin());
tv_lose.setText(clubInfo.getLose());
tv_pg.setText(clubInfo.getPing());
tv_jf.setText(clubInfo.getJifen());
//显示图片
bitmapUtils.display(imageView_cm,clubInfo.getClubimage().getFileUrl(context));
return convertView;
}
public ArrayList<ClubInfo>getClubInfos(){
return clubInfos;
}
public void setClubInfos(ArrayList<ClubInfo> clubInfos) {
this.clubInfos = clubInfos;
}
}

dxw
