我有客户适配器:
angular.module('services.security', [])
.provider('securityService', function() {
this.$get = function ($q, $location, $rootScope, $window, $injector) {
...
loginCheck: function(username, password) {
var failed = true;
$injector.get('$http').post(AUTH_URL,
{username: username, password: password}, {loginType: "cancel"}
).success(function loginSuccess(data) {
failed = false;
}).error(function loginFailure(data, status) {
failed = true;
});
return failed;
},
这一行:
public class AdapterListGroups extends BaseAdapter {
private List<ItemMusicGroup> listItemsMusicGroup;
private LayoutInflater layoutInflater;
final private String division = " ";
public AdapterListGroups(Context context, List<ItemMusicGroup> listItemsMusicGroup) {
this.listItemsMusicGroup = listItemsMusicGroup;
this.layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return this.listItemsMusicGroup.size();
}
@Override
public Object getItem(int position) {
return this.listItemsMusicGroup.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if ( view == null ) {
view = layoutInflater.inflate(R.layout.list_item, parent, false);
}
setContentItem(view, position);
return view;
}
private void setContentItem(View view, int position)
{
ImageView imageView = (ImageView) view.findViewById(R.id.item_imageView_icon);
imageView.setImageResource(R.drawable.asses);
ItemMusicGroup currentItemMusicGroup = getItemMusicGroup(position);
TextView nameGroup = (TextView) view.findViewById(R.id.item_textView_nameGroup);
nameGroup.setText(currentItemMusicGroup.getName());
if ( currentItemMusicGroup.getCountAlbum() != null ) {
TextView countAlbum = (TextView) view.findViewById(R.id.list_item_textView_countAlbum);
countAlbum.setText(currentItemMusicGroup.getCountAlbum() + this.division + R.string.list_item_textView_countSing);
}
}
public ItemMusicGroup getItemMusicGroup(int position) {
return (ItemMusicGroup) getItem(position);
}
}
我想在此类中使用我自己的文本+字符串的const(函数getString(id)不起作用)自定义countAlbum TextView的文本。
这里我得到自己的文字+ int(idResourse)。
我该怎么做? 谢谢!
答案 0 :(得分:1)
您需要使用 getResources()。getString(R.string.example)
尝试:
countAlbum.setText(currentItemMusicGroup.getCountAlbum() + this.division + countAlbum.getContext().getResources().getString(R.string.list_item_textView_countSing));