求助!一简单的listView加载问题

win-sun win-sun 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
package com.xyyj.sharefeelingsapp.page;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.xyyj.sharefeelingsapp.R;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

@SuppressLint({ "ValidFragment", "NewApi" })
public class RecordMood extends Fragment {
private View view;
private ListView recordlist;
private Map<String,Object> picUrlMap;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.recordmood,null);
recordlist = (ListView) view.findViewById(R.id.recordlist);
initList();
return view;
}

public void initList() {
List<Map<String,Object>> data = new ArrayList<Map<String,Object>>();
picUrlMap = new HashMap<String,Object>();
picUrlMap.put("pic",R.drawable.pic1);
picUrlMap.put("text", "测试一");
data.add(picUrlMap);

/* picUrlMap = new HashMap<String,Object>();
picUrlMap.put("pic",R.drawable.pic2);
picUrlMap.put("text", "测试一");
data.add(picUrlMap);

picUrlMap = new HashMap<String,Object>();
picUrlMap.put("pic",R.drawable.pic3);
picUrlMap.put("text", "测试一");
data.add(picUrlMap);
*/
SimpleAdapter adapter = new SimpleAdapter(getActivity().getApplicationContext(), data,
R.layout.recordlist_item, new String[]{"pic","text"}, new int[]{R.id.gif,R.id.text});
recordlist.setAdapter(adapter);
adapter.notifyDataSetChanged();
}

}

recordlist_item.xml:

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

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="80dp" >

<com.ant.liao.GifView
android:id="@+id/gif"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:enabled="false"
android:onClick="recordClick"
android:src="@drawable/pic1" />
<!--
<ImageView
android:id="@+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo_qzone" /> -->

<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignBottom="@+id/gif"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/gif"
android:text="测试" />

</RelativeLayout>

</LinearLayout>

就是不显示,不知道那里出错了?
...全文
评论 10
收藏 已收藏
分享
返回顶部
win-sun
Android 80,490 成员 91,371 内容