Как я могу изменить fontstyle в своем списке? Я не знаю, что я должен сделать, чтобы изменить свой шрифт, спасибо за вашу помощь.Изменить fontstyle в simpleadapter listview
Как изменить шрифт в моем списке? Я не знаю, что я должен сделать, чтобы изменить свой шрифт, спасибо за вашу помощь.
это мой код:
public class ListViewFrame extends Activity {
SharedPreferences sharedpreferences;
// Array of strings storing country names
String[] countries = new String[] { "Frame1", "Frame2", "Frame3", "Frame4", };
// Array of integers points to images stored in /res/drawable-ldpi/
int[] flags = new int[] { R.drawable.framesone, R.drawable.framestwo,
R.drawable.framesthree, R.drawable.framesfour, };
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.acmain);
sharedpreferences = this.getSharedPreferences(AppConstant.MyPREFERENCES,
Context.MODE_PRIVATE);
List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();
for(int i=0;i<4;i++){
HashMap<String, String> hm = new HashMap<String,String>();
hm.put("txt", countries[i]);
hm.put("flag", Integer.toString(flags[i]));
aList.add(hm);
}
// Keys used in Hashmap
String[] from = { "flag","txt" };
// Ids of views in listview_layout
int[] to = { R.id.flag,R.id.txt};
// Instantiating an adapter to store each items
// R.layout.listview_layout defines the layout of each item
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), aList, R.layout.listview_layout, from, to);
// setFontTextView(this,);
// Getting a reference to listview of main.xml layout file
ListView listView = (ListView) findViewById(R.id.listview);
// Setting the adapter to the listView
listView.setAdapter(adapter);
Вам нужен пользовательский адаптер. Проверьте [это] (http://stackoverflow.com/a/18933258/2176708) – Hemanth
Пользовательский базовый адаптер для настройки .. проверьте http://stackoverflow.com/a/28105884/1140237. его оптимизировано с использованием шаблона Holder для повторного использования вида, который создается – user1140237