我的应用中有一个这样的自定义列表视图,没有标题部分。现在我需要在listview的顶部添加一个标题,如图所示。如何将其添加到我的自定义列表视图中。自定义列表视图是片段活动。有一点需要注意的是,我希望标题显示在malayalam(Utf-8)而不是英文(ascii)。我的自定义列表视图中的名称和名称位于malayalam中。我在我的应用程序中使用Typeface完成了这项工作。但我不知道如何在自定义列表视图中显示malayalam中的标题。提前谢谢..
这是我的customlistviewadapter.class的代码。
public class CustomListViewAdapter extends ArrayAdapter<RowItem>{
Typeface tf;
Context context;
public CustomListViewAdapter(Context context, int resourceId,
List<RowItem> items) {
super(context, resourceId, items);
this.context = context;
}
/*private view holder class*/
private class ViewHolder {
ImageView imageView;
TextView name;
TextView designation;
TextView phonenumber;
// Helper help=new Helper(context);
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
ImageButton call,sms;
final RowItem rowItem = getItem(position);
final LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_single, null);
holder = new ViewHolder();
tf=Typeface.createFromAsset(getContext().getAssets(),"MLKR0NTT.TTF");
holder.name = (TextView) convertView.findViewById(R.id.text1);
holder.designation = (TextView) convertView.findViewById(R.id.text);
holder.phonenumber=(TextView)convertView.findViewById(R.id.text2);
holder.imageView = (ImageView) convertView.findViewById(R.id.image);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
holder.name.setText(rowItem.getName());
holder.designation.setText(rowItem.getDesignation());
holder.name.setTypeface(tf);
holder.designation.setTypeface(tf);
holder.phonenumber.setText(rowItem.getPhone());
holder.imageView.setImageBitmap(rowItem.getImage());
call=(ImageButton)convertView.findViewById(R.id.callbutton);
sms=(ImageButton)convertView.findViewById(R.id.smsbutton);
sms.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("sms:"+rowItem.getPhone()));
smsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
smsIntent.putExtra("sms_body", "");
context.startActivity(smsIntent);
}
});
call.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(), "Calling...", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("tel:" +rowItem.getPhone()));
context.startActivity(intent);
}
});
return convertView;
}
}
答案 0 :(得分:1)
只需用您需要的任何语言拍摄文字图像,然后通过传递该视图使用listview的addHeaderView(您的在此视图)方法......