【发布时间】:2020-02-21 16:01:27
【问题描述】:
/*JAVA File*/ArrayList<UserObject> userList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find_user);
initializeRecyclerView();
}
private void initializeRecyclerView() {
mUserList=findViewById(R.id.userList);
mUserList.setNestedScrollingEnabled(false);
mUserList.setHasFixedSize(false);
mUserListLayoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayout.VERTICAL, false);
mUserList.setLayoutManager(mUserListLayoutManager);
mUserListAdapter =new UserList(userList);
mUserList.setAdapter(mUserListAdapter);
}
XML 文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FindUserActivity">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/userList"
android:scrollbars="vertical">
</androidx.recyclerview.widget.RecyclerView>
线:mUserListLayoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayout.VERTICAL, false);
提供警告:必须是 RecyclerView.HORIZONTAL 或 RecyclerView.VERTICAL 之一 问题 ID:错误常量
【问题讨论】:
标签: java android android-studio