0

マップを使用して値をカスタム アダプターに渡しています。カスタム アダプタで値を取得するにはどうすればよいですか。私のアプリはエラーなしで空白の画面を表示しています。

javaファイル

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

public class archive extends Fragment {
    public archive() {
    }

    private archiveadapter tableRowAdapter;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.v("ListFragment", "onCreate()");
    }

    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.v("ListFragment", "onActivityCreated().");
        Log.v("ListsavedInstanceState", savedInstanceState == null ? "true"
                : "false");

        // Generate list View from ArrayList
        displayListView();

    }

    public static final String ARG_SECTION_NUMBER = "section_number";

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View v = inflater
                .inflate(R.layout.moderationrequests, container, false);

        return v;
    }

    private void displayListView() {

        List<String> dialogtitle = new ArrayList<String>();
        dialogtitle
                .add("Thief nabbed selling stolen mower to owner: Stupid, Clever or Calculated?");
        dialogtitle
                .add("Will software development as a skilled profession ever become obsolete and possible by the average person?");

        List<String> membername = new ArrayList<String>();
        membername.add("By Pegasus");
        membername.add("By Andrew");

        List<String> postedon = new ArrayList<String>();
        postedon.add("6 months ago on Current Affairs");
        postedon.add("6 months ago on Current Affairs");

        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
        Map<String, String> map;
        int count = dialogtitle.size();
        for (int i = 0; i < dialogtitle.size(); i++) {
            map = new HashMap<String, String>();
            map.put("dialogtitle", dialogtitle.get(i));
            map.put("membername", membername.get(i));
            map.put("postedon", postedon.get(i));
            list.add(map);
        }


        tableRowAdapter = new archiveadapter(getActivity(),
                R.layout.dialog_archive_list, list);
        ListView listView = (ListView) getView().findViewById(R.id.list_view);

        listView.setAdapter(tableRowAdapter);


    }
}

アダプタ

   public class archiveadapter extends ArrayAdapter< List<Map<String,String>>> {
        private final Context context;
        private final List<Map<String, String>> names;
        private Button deleteButton = null;

        public archiveadapter(Context context, int itemResId,  List<Map<String,String>> names) {
            super(context, itemResId);
            this.context = context;
            this.names = names;

        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // LayoutInflater inflater = context.getLayoutInflater();
            // View rowView = inflater.inflate(R.layout.mod_req_list, null, true);

            View rowView = convertView;
            if (rowView == null) {
                LayoutInflater inflater = LayoutInflater.from(context);
                rowView = inflater.inflate(R.layout.dialog_archive_list, null);

            }
            TextView archivetitle = (TextView) rowView
                    .findViewById(R.id.dialogarchive_title);

            Map<String, String> map = names.get(position);
            //String link = map.get("Link");


            archivetitle.setText(map.get("dialogtitle"));
            TextView membername = (TextView) rowView.findViewById(R.id.membername);
            membername.setText(names.get(1).toString());
            TextView votes = (TextView) rowView.findViewById(R.id.postedon);
            votes.setText(names.get(2).toString());

            return rowView;
        }

    }

アイデアや提案はありますか?ありがとう、

4

1 に答える 1