如何以在android中插入字符串数组的相同顺序显示列表视图

时间:2015-03-16 06:50:15

标签: android arrays listview android-fragments

你好我有Listview,其中包含字符串数组中的12项,列表扩展了Fragment.My问题是列表项位置没有显示正确的order.here在我的代码下面..

这是值文件夹字符串数组

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="list_of_suryanamaskar">
      <item>Salutation Position</item>
      <item>Raised Arm Position</item>
      <item>Hand to Foot Position</item>
      <item>Equestrian Position</item>
      <item>Mountain Position</item>
      <item>Salutation with Eigth Limbs</item>
      <item>Cobra Position</item>
      <item>Mountain Position</item>
      <item>Equestrian Position</item>
      <item>Hand to Foot Position</item>
      <item>Raised Arm Position</item>
      <item>Salution Position</item>
      </string-array>
  </resource>

这是我的listfragment代码

public class SuryanamaskarFragment extends Fragment {
    String[] strname;
    TypedArray image;

List<BackBonerowItem> rowItems;
ListView mylistview;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.customlist_main, container,
            false);

    rowItems = new ArrayList<BackBonerowItem>();
    image = getResources().obtainTypedArray(
            R.array.list_of_suryanamaskarimage);
    strname = getResources().getStringArray(R.array.list_of_suryanamaskar);

    for (int i = 0; i < strname.length; i++) {
        BackBonerowItem item = new BackBonerowItem(strname[i],
                image.getResourceId(i, -1));
        image.recycle();
        rowItems.add(item);

    }

    mylistview = (ListView) rootView.findViewById(R.id.list);
    BackBoneCustomAdoptor adapter = new BackBoneCustomAdoptor(
            getActivity(), rowItems);
    mylistview.setAdapter(adapter);

0 个答案:

没有答案