列出返回奇怪的值,如" com.package.project@79dd0d3"

时间:2015-08-23 03:38:26

标签: java android xml realm

我正在尝试从Realm数据库中提取一些数据并将其显示在回收站视图中。目前,回收者视图显示了许多条目,如" com.package.project@79dd0d3"。这是我的代码:

 @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View layout = inflater.inflate(R.layout.fragment_acronyms_list, container, false);
    acronymList = (RecyclerView) layout.findViewById(R.id.acronymRecyclerView);
    addNewEntry = (FloatingActionButton) layout.findViewById(R.id.addBtn);

    realmDB = Realm.getInstance(getActivity());
    realmResults = realmDB.allObjects(RealmAcronym.class);
    realmResults.sort("acronym");

    acronymTitlesList = getAcronymTitles();

    adapter = new acronymListAdapter(getActivity(), getData());
    acronymList.setAdapter(adapter);
    acronymList.setLayoutManager(new LinearLayoutManager(getActivity()));

    return layout;
}

public static List<acronymEntry> getData() {
    List<acronymEntry> data = new ArrayList<>();
    int size = acronymTitlesList.size();
    if(size != 0) {
        for (int i = 0; i < size; i++) {
            acronymEntry current = new acronymEntry();
            current.title = String.valueOf(acronymTitlesList.get(i));
            data.add(current);
        }
    }

    return data;
}

public static List<AcronymTitle> getAcronymTitles() {
    List<AcronymTitle> data = new ArrayList<>();

    String tempAcronym = new String();

    for(RealmAcronym acronymObject : realmResults){
        tempAcronym = acronymObject.getAcronym();
        AcronymTitle current = new AcronymTitle();
        current.title = tempAcronym;
        data.add(current);
    }

    return data;
}

如何显示列表的实际值而不是当前显示的值。

0 个答案:

没有答案