在listitem上更改textview的字体样式是否单击?

时间:2015-04-16 12:28:51

标签: android

如何设置textview字体单击listvite项目上的样式。如果我从列表中选择第一个项目然后我的textview fontstye1然后当我从列表中选择第二个或第三个项目时更改我的textview fontstyle2或fontstyle3。

Typeface type = Typeface.createFromAsset(getAssets(), "fontstyle1");
Typeface type = Typeface.createFromAsset(getAssets(), "fontstyle2");
Typeface type = Typeface.createFromAsset(getAssets(), "fontstyle3");
txtView.setTypeface(type);

1 个答案:

答案 0 :(得分:0)

  

如何设置textview字体单击listvite项目上的样式

使用onItemClick更改所选行的文字颜色:

 public void onItemClick(AdapterView<?> parent, View view,int position, long id) 
      {
           TextView txtView = (TextView)view.findViewById(R.id.textview_id);
           Typeface type = Typeface.createFromAsset(view.getContext().getAssets(),
                                                         "fontstyle"+(position+1)); 
           txtView.setTypeface(type);   
    }});