カスタムアダプターTextView
で使用しているカスタムがあります。GridView
カスタムTextView
は、翻訳目的でカスタム フォントを使用しています。これは、デフォルトでロケールがインストールされているデバイスでかなりうまく機能します。
ただし、言語がインストールされていないデバイスでは、奇妙な動作が表示されます。アプリが初めて読み込まれるとき、TextViews
カスタム フォントで表示されません。ただし、更新ボタンを押してフラグメントをリロードするTextViews
と、カスタムフォントで表示されます。
なぜこれが起こっているのかわかりません。
Adapters
これは、カスタムを使用しているアプリケーションのすべてのカスタムで発生していますTextView
。
かなり基本的なアダプター:
public class CalendarWeekAdapter extends BaseAdapter{
private String[] weekdays;
Context mContext;
private LayoutInflater mInflater;
public CalendarWeekAdapter(Context context, int firstDay)
{
mContext=context;
mInflater = LayoutInflater.from(context);
weekdays = context.getResources().getStringArray(R.array.weekdays);
}
public int getCount()
{
return weekdays.length;
}
public Object getItem(int position)
{
return position;
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder holder=null;
if(convertView==null)
{
convertView = mInflater.inflate(R.layout.calendar_week, parent,false);
holder = new ViewHolder();
holder.txtWeekdays=(CustomTextView)convertView.findViewById(R.id.weekdays);
if(position==0)
{
convertView.setTag(holder);
}
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.txtWeekdays.setText(weekdays[position]);
return convertView;
}
}
class ViewHolder
{
CustomTextView txtWeekdays;
}
基本的な CustomTextView:
public class CustomTextView extends TextView {
public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public CustomTextView(Context context) {
super(context);
init();
}
private void init() {
if (!isInEditMode()) {
setTypeface(Utils.getFont(getContext()));
}
}
}