質問

I populate my menu items with menu_items.xml, which is located in values.

my menu_items.xml looks like:

<?xml version="1.0" encoding="utf-8"?>

<string-array name="menu_items">
   <item ><b><u>Where to stay</u></b></item>
   <item ><b><u>Where to eat</u></b></item>
   <item ><b><u>What to see</u></b></item>
   <item ><b><u>Usefull info</u></b></item>
</string-array>

This is part of code from MainActivity.java where i get these values between tags:

private ListView lvMenu;
private CharSequence[] lvMenuItems;  //CharSequence[] allow to bold text between <item></item> tags

...

lvMenuItems =  getResources().getTextArray(R.array.menu_items); 
    lvMenu = (ListView) findViewById(R.id.menu_listview);
    lvMenu.setAdapter(new ArrayAdapter<CharSequence>(this,
            android.R.layout.simple_list_item_1, lvMenuItems));

I created database, and all of these stuff. Now, i wanna to put some titles from database between tags. Can you help me to solve that issue. Thank you. Tell me if u need more info.

役に立ちましたか?

解決

replace the getTextArray to getStringArray and it must be String[]

 String[] some_array = getResources().getStringArray(R.array.menu_items)

use Spanned to make the items bold and underline

 for(int i=0;i<some_array.length;i++){

    Spanned[] lvMenuItems =
new Spanned(Html.fromHtml("<b><u>"+some_array.get(i))+"<b><u>");
    }

change to Spanned type ArrayAdapter<Spanned> arrayadapter

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top