Пробовал отключать InstantRun, проверил все возможные ошибки но ничего не нашел. Вот код :
fragment
public RecyclerView mRecyclerView;
ListFreindsAdapter mAdapter;
public RecyclerView.LayoutManager mLayoutManager;
private VKList<VKApiUserFull> list;
public FragmentAcount() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_acount, container, false);
mRecyclerView = (RecyclerView)v.findViewById(R.id.rview);
mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new ListFreindsAdapter(getActivity(), list = new VKList<>());
mRecyclerView.setAdapter(mAdapter);
showFriends();
return v;
}
private void showFriends() {
final VKRequest request = VKApi.friends().get(VKParameters.from(VKApiConst.FIELDS, "first_name, last_name"));
request.executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
super.onComplete(response);
list.clear();
list.addAll((VKList<VKApiUserFull>) response.parsedModel);
mAdapter.setNewList(list);
}
});
}
layout fragment
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rview"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
adapter
public class ListFreindsAdapter extends RecyclerView.Adapter<ListFreindsAdapter.ViewHolder> {
private Context context;
private VKList<VKApiUserFull> list;
public ListFreindsAdapter(Context context, VKList<VKApiUserFull> list) {
this.context = context;
this.list = list;
}
public void setNewList(VKList<VKApiUserFull> list){
this.list = list;
notifyDataSetChanged();
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_freinds_recycler, parent, false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.nameFriend.setText("A" + list.get(position).first_name.toString());
}
@Override
public int getItemCount() {
return list == null ? 0 : list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private TextView nameFriend;
public ViewHolder(View v) {
super(v);
nameFriend = (TextView)v.findViewById(R.id.nameFriend);
}
}
}
layuot adapter
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/nameFriend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>