我想在导航抽屉中放置底部ListView的TextView.抛出java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="0dp"
android:paddingBottom="4dp"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="240dp"
android:layout_height="match_parent"
android:id="@+id/left_drawer"
android:layout_gravity="start"
>
<ListView
android:id="@+id/left_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:dividerHeight="0.1dp"
android:background="#111"
android:divider="#FFF"
/>
<TextView
android:id="@+id/joke_text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:lineSpacingExtra="5sp"
android:text="AAAAAA"
/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
// Getting reference to the DrawerLayout
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer);
leftMenuItems = getResources().getStringArray(R.array.leftMenuItems);
mDrawerList = (ListView) findViewById(R.id.left_menu);
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
// set a custom shadow …Run Code Online (Sandbox Code Playgroud) 我正在开发应用程序,在应用程序启动时,我从 Rest 服务下载类别和帖子,以便将它们存储在 SQLite 数据库中。我有几个问题:
objects变量很奇怪。代码:
ItemsApi client = this.getClient(); // Retrofit2
List<Observable<?>> requests = new ArrayList<>();
requests.add(client.getCategories());
requests.add(client.getPosts());
Observable<Object> combined = Observable.zip(
requests,
new Function<Object[], Object>() {
@Override
public Object apply(Object[] objects) throws Exception {
Timber.d("Length %s", objects.length); // Length 2
Timber.d("objects.getClass() %s", objects.getClass()); // objects.getClass() class [Ljava.lang.Object;
return new Object();
}
});
Disposable disposable = combined.subscribe(
new Consumer<Object>() {
@Override
public void accept(Object o) throws Exception {
Timber.d("Object %s", o.toString());
} …Run Code Online (Sandbox Code Playgroud)