解决方案 »

  1.   

    建议用String.xml不要自己去写,,,
      

  2.   

    你在UTF-8下面写文本,把项目都统一成一个字符编码,注意全角半角。
      

  3.   

    我把有关导航栏的代码都粘出来,帮忙会诊一下:1、导航栏数组文件:arrays.xml
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string-array name="categories">
            <item>1|焦点</item>
            <item>2|国内</item>
            <item>3|国际</item>
            <item>4|军事</item>
            <item>5|体育</item>
            <item>6|科技</item>
            <item>7|汽车</item>
            <item>8|财经</item>
            <item>9|游戏</item>
            <item>10|女人</item>
        </string-array>
    </resources>
    2、导航栏绑定代码
    //获取新闻分类
    String[] categoryArray = getResources().getStringArray(R.array.categories);
    //把新闻分类保存到List中
    final List<HashMap<String, Category>> categories = new ArrayList<HashMap<String, Category>>();
    //分割新闻类型字符串
    for(int i=0;i<categoryArray.length;i++)
    {
    String[] temp = categoryArray[i].split("[|]");
    if (temp.length==2)
    {
    int cid = StringUtil.String2Int(temp[0]);
    String title = temp[1];
    Category type = new Category(cid, title);
    HashMap<String, Category> hashMap = new HashMap<String, Category>();
    hashMap.put("category_title", type);
    categories.add(hashMap);
    }
    }
    //默认选中的新闻分类
    mCid = 1;
    //创建Adapter,指明映射字段
    CustomSimpleAdapter categoryAdapter = new CustomSimpleAdapter(this, categories, R.layout.category_title, new String[]{"category_title"}, new int[]{R.id.category_title});

    GridView category = new GridView(this);
    category.setColumnWidth(mColumnWidthDip);//每个单元格宽度
    category.setNumColumns(GridView.AUTO_FIT);//单元格数目
    category.setGravity(Gravity.CENTER);//设置对其方式
    //设置单元格选择是背景色为透明,这样选择时就不现实黄色北京
    category.setSelector(new ColorDrawable(Color.TRANSPARENT));
    //根据单元格宽度和数目计算总宽度
    int width = mColumnWidthDip * categories.size();
    LayoutParams params = new LayoutParams(width, LayoutParams.FILL_PARENT);
    //更新category宽度和高度,这样category在一行显示
    category.setLayoutParams(params);
    //设置适配器
    category.setAdapter(categoryAdapter);
    //把category加入到容器中
    LinearLayout categoryList = (LinearLayout) findViewById(R.id.category_layout);
    categoryList.addView(category);
    //添加单元格点击事件