private class FriendListAdapter extends BaseAdapter
{
class ViewHolder {
TextView text;
ImageView icon;
}
private LayoutInflater mInflater;
private Bitmap mOnlineIcon;
private Bitmap mOfflineIcon;
private FriendInfo[] friends = null;
public FriendListAdapter(Context context) {
super();
mInflater = LayoutInflater.from(context);
mOnlineIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.greenstar);
mOfflineIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.redstar);
}
public void setFriendList(FriendInfo[] friends)
{
this.friends = friends;
}
public int getCount() {
return friends.length;
}
public FriendInfo getItem(int position) {
return friends[position];
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
// When convertView is not null, we can reuse it directly, there is no need
// to reinflate it. We only inflate a new View when the convertView supplied
// by ListView is null.
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.friend_list_screen, null);
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(holder);
}
else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}
// Bind the data efficiently with the holder.
holder.text.setText(friends[position].userName);
holder.icon.setImageBitmap(friends[position].status == STATUS.ONLINE ? mOnlineIcon : mOfflineIcon);
return convertView;
}
}
如何在我的输出textview中制作一些像泡泡语音?
答案 0 :(得分:0)
class ProductsAdapter extends BaseAdapter {
Context _scontext;
LayoutInflater _inflater;
ArrayList<ProductsDataModel> data;
public ProductsAdapter(Context context,ArrayList<ProductsDataModel> arraylist) {
this._scontext = context;
data = arraylist;
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
TextView ends_in,discount_rate;
ImageView set_product_image;
Button go_for_sale;
_inflater = (LayoutInflater) _scontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = _inflater.inflate(R.layout.product_display_custom_layout_phone, parent, false);
ends_in = (TextView) itemView.findViewById(R.id.set_time_left);
discount_rate = (TextView) itemView.findViewById(R.id.set_discount);
set_product_image =(ImageView) itemView.findViewById(R.id.product_image);
go_for_sale = (Button) itemView.findViewById(R.id.go_for_sale);
go_for_sale.setTag(position);
set_product_image.setTag(position);
Typeface mFont = Typeface.createFromAsset(getActivity().getAssets(), "fonts/georgia.ttf");
ends_in.setTypeface(mFont);
discount_rate.setTypeface(mFont);
ProductsDataModel obj=data.get(position);
long timeInMilliseconds = Long.valueOf(obj.getEnds_at());
long end = timeInMilliseconds * 1000;
long current = System.currentTimeMillis();
long diff = end - current;
int dayCount = (int) diff / (24 * 60 * 60 * 1000);
int hours_left = (int) ((diff / (1000 * 60 * 60)) % 24);
int minutes_left = (int) ((diff / (1000 * 60 )) % 60);
int seconds_left = (int) ((diff/1000)%60);
System.out.println("A"+hours_left);
System.out.println("B"+minutes_left);
System.out.println("C"+seconds_left);
String s = Integer.toString(dayCount) + " Days" +" "+ Integer.toString(hours_left) + ":" + Integer.toString(minutes_left) + ":" + Integer.toString(seconds_left);
ends_in.setText(s);
discount_rate.setText(obj.getDiscount_text());
String a="https:"+obj.getTeaser_url();
System.out.println("value of a is+"+a);
AQuery aq = new AQuery(_scontext);
aq.id(set_product_image).image(a);
return itemView;
}
}
答案 1 :(得分:0)
您需要创建一个drawable并将其设置为背景视图的背景。
res / drawable中的(你可能需要创建drawable文件夹)创建bubbleback.xml和 添加以下代码
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffffff"/>
<stroke android:width="1dp"
android:color="#ff000000"
/>
<padding android:left="3dp"
android:top="3dp"
android:right="3dp"
android:bottom="3dp"
/>
<corners android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
保存并将friend_list_screen的最顶层视图的背景设置为冒泡drawable。