我想为arraylist实施徽章。但我不能。
此徽章类:https://github.com/jgilfelt/android-viewbadger/
这个github页面有一个arraylist的例子。它在这里:https://github.com/jgilfelt/android-viewbadger/blob/master/src/viewbadger/demo/DemoActivity.java它从第290行开始。
这是我的数组适配器方法:
conversationsAdapter=new ArrayAdapter<JsonObject>(this,0) {
@Override
public View getView(int c_position,View c_convertView,ViewGroup c_parent) {
if (c_convertView == null) {
c_convertView=getLayoutInflater().inflate(R.layout.random_bars,null);
}
JsonObject user=getItem(c_position);
String name=user.get("name").getAsString();
String image_url="http://domain.com/photos/profile/thumb/"+user.get("photo").getAsString();
TextView nameView=(TextView)c_convertView.findViewById(R.id.tweet);
nameView.setText(name);
ImageView imageView=(ImageView)c_convertView.findViewById(R.id.image);
Ion.with(imageView)
.placeholder(R.drawable.twitter)
.load(image_url);
return c_convertView;
}
};
ListView conversationsListView = (ListView)findViewById(R.id.conversationList);
conversationsListView.setAdapter(conversationsAdapter);
conversationsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//Log.w("Pos","asd"+randomAdapter.getItem(position).get("name").getAsString());
startChat(conversationsAdapter.getItem(position));
}
});
我想为每一行添加徽章。我该怎么做?