我想在我的主活动中使用Umano/SlidingUpPanel
这是我的activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DemoActivity" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/lib/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp"
sothree:paralaxOffset="100dp"
sothree:dragView="@+id/name">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?android:attr/actionBarSize">
<Button
android:id="@+id/bigbutton_right"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignBaseline="@+id/bigbutton_middle"
android:layout_alignBottom="@+id/bigbutton_middle"
android:layout_marginLeft="7dp"
android:layout_toRightOf="@+id/bigbutton_middle"
android:onClick="selectFrag"
android:background="@drawable/mainbutton_right" />
<Button
android:id="@+id/bigbutton_left"
android:layout_width="100dp"
android:layout_height="100dp"
android:onClick="selectFrag"
android:layout_alignBaseline="@+id/bigbutton_middle"
android:layout_alignBottom="@+id/bigbutton_middle"
android:layout_marginRight="7dp"
android:layout_toLeftOf="@+id/bigbutton_middle"
android:background="@drawable/mainbutton_left" />
<Button
android:id="@+id/bigbutton_middle"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="138dp"
android:background="@drawable/mainbutton_middle"
android:onClick="selectFrag" />
<fragment
android:id="@+id/fragment_place"
android:name="com.mainpackage.FragmentOne"
android:layout_width="match_parent"
android:layout_height="340dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/bigbutton_right"
android:layout_marginTop="14dp" />
<TextView
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Main Content"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="true"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eeeeee"
android:orientation="vertical"
android:clickable="true"
android:focusable="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal">
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="10dp"/>
<Button
android:id="@+id/follow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="14sp"
android:gravity="center_vertical|right"
android:paddingRight="10dp"
android:paddingLeft="10dp"/>
</LinearLayout>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>
这是我的mainactivity。java
package com.mainpackage;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
public class MainActivity extends Activity {
int t=1;
int oldt=1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
one=(Button)findViewById(R.id.bigbutton_left);
two=(Button)findViewById(R.id.bigbutton_middle);
three=(Button)findViewById(R.id.bigbutton_right);
one.setBackgroundResource(R.drawable.button_full_gen_pressed);
}
Button one;
Button two;
Button three;
public void selectFrag(View view) {
Fragment fr;
one.setBackgroundResource(R.drawable.button_full_gen_normal);
two.setBackgroundResource(R.drawable.button_chap_gen_normal);
three.setBackgroundResource(R.drawable.button_ncert_normal);
if(view == findViewById(R.id.bigbutton_middle)) {
fr = new FragmentTwo();
t=2;
two.setBackgroundResource(R.drawable.button_chap_gen_pressed);
}else if(view==findViewById(R.id.bigbutton_right)) {
fr = new FragmentThree();
t=3;
three.setBackgroundResource(R.drawable.button_ncert_pressed);
}
else {
one.setBackgroundResource(R.drawable.button_full_gen_pressed) ;
t=1;
fr=new FragmentOne();
}
FragmentManager fm = getFragmentManager();
FragmentTransaction fragmentTransaction = fm.beginTransaction();
if(oldt!=t)
{ fragmentTransaction.setCustomAnimations(R.anim.slide_in, R.anim.slide_out);
oldt=t;
}
else
{
fragmentTransaction.setCustomAnimations(R.anim.none, R.anim.none);
}
fragmentTransaction.replace(R.id.fragment_place, fr);
fragmentTransaction.commit();
}
}
当我编译时,代码编译了,但是它崩溃了,并出现以下错误代码:
E/AndroidRuntime(4126): FATAL EXCEPTION: main 05-22 08:57:12.884: E/AndroidRuntime(4126):java.lang.RuntimeException:无法启动活动ComponentInfo {com.mainpackage/com.mainpackage.MainActivity}:android.view.InflateException:二进制XML文件行#6:错误膨胀类com. sothree.slidinguppanpanel . slidinguppanellayout 05-2208:57:12.884: E/AndroidRuntime(4126): atandroid.app.ActivityThread.performLaunchActivity (ActivityThread.java: 1956)05-22 08:57:12.884: E/AndroidRuntime(4126): atandroid.app.ActivityThread.handleLaunchActivity (ActivityThread.java: 1981)05-22 08:57:12.884: E/AndroidRuntime(4126): at(ActivityThread.java: 123) 05-22 android.app.ActivityThread.access 600美元08:57:12.884: E/AndroidRuntime(4126): atandroid.app.ActivityThread H.handleMessage美元(ActivityThread.java: 1147)05-22 08:57:12.884: E/AndroidRuntime(4126): atandroid.os.Handler.dispatchMessage 05-22 (Handler.java: 99)08:57:12.884: E/AndroidRuntime(4126): atandroid.os. loop .loop(loop .java:137) 05-22 08:57:12.884:E/AndroidRuntime (4126):android.app.ActivityThread.main 05-22 (ActivityThread.java: 4424)08:57:12.884: E/AndroidRuntime(4126): atjava.lang.reflect.Method。invokeNative(原生方法)05-2208:57:12.884: E/AndroidRuntime(4126): atjava.lang.reflect.Method.invoke(Method.java:511) 05-22 08:57:12.884:E/AndroidRuntime (4126):com.android.internal.os.ZygoteInit MethodAndArgsCaller.run美元(ZygoteInit.java: 825)05-22 08:57:12.884: E/AndroidRuntime(4126): atcom.android.internal.os.ZygoteInit.main 05-22 (ZygoteInit.java: 592)08:57:12.884: E/AndroidRuntime(4126): atdalvik.system.NativeStart。main(本地方法)05-22 08:57:12.884:E/AndroidRuntime(4126): Caused by: android.view.InflateException:二进制XML文件行#6:错误膨胀类slidinguppanellayout 05:22 08:57:12.884:E/AndroidRuntime (4126):android.view.LayoutInflater.createViewFromTag (LayoutInflater.java: 691)05-22 08:57:12.884: E/AndroidRuntime(4126): atandroid.view.LayoutInflater.rInflate 05-22 (LayoutInflater.java: 739)08:57:12.884: E/AndroidRuntime(4126): atandroid.view.LayoutInflater.inflate 05-22 (LayoutInflater.java: 489)08:57:12.884: E/AndroidRuntime(4126): atandroid.view.LayoutInflater.inflate 05-22 (LayoutInflater.java: 396)08:57:12.884: E/AndroidRuntime(4126): atandroid.view.LayoutInflater.inflate 05-22 (LayoutInflater.java: 352)08:57:12.884: E/AndroidRuntime(4126): atcom.android.internal.policy.impl.PhoneWindow.setContentView (PhoneWindow.java: 251)05-22 08:57:12.884: E/AndroidRuntime(4126): atandroid.app.Activity.setContentView 05-22 (Activity.java: 1835)08:57:12.884: E/AndroidRuntime(4126): atcom.mainpackage.MainActivity.onCreate 05-22 (MainActivity.java: 26)08:57:12.884: E/AndroidRuntime(4126): atandroid.app.Activity.performCreate 05-22 (Activity.java: 4465)08:57:12.884: E/AndroidRuntime(4126): atandroid.app.Instrumentation.callActivityOnCreate (Instrumentation.java: 1051)05-22 08:57:12.884: E/AndroidRuntime(4126): atandroid.app.ActivityThread.performLaunchActivity (ActivityThread.java: 1920)05-22 08:57:12.884: E/AndroidRuntime(4126):…11 more 05-2208:57:12.884: E/AndroidRuntime(4126): Caused by:java.lang.ClassNotFoundException:slidinguppanellayout 05:22 08:57:12.884:E/AndroidRuntime (4126):dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java: 61)05-22 08:57:12.884: E/AndroidRuntime(4126): atjava.lang.ClassLoader.loadClass 05-22 (ClassLoader.java: 501)08:57:12.884: E/AndroidRuntime(4126): atjava.lang.ClassLoader.loadClass 05-22 (ClassLoader.java: 461)08:57:12.884: E/AndroidRuntime(4126): atandroid.view.LayoutInflater.createView 05-22 (LayoutInflater.java: 552)08:57:12.884: E/AndroidRuntime(4126): atandroid.view.LayoutInflater.createViewFromTag (LayoutInflater.java: 680)
我做错了什么?
您是否添加了jar文件或将整个源代码复制到您的工作空间…问题似乎在这一行,而使用自定义视图:<com.sothree.slidinguppanel.SlidingUpPanelLayou
并且确保SlidingUpPanelLayout
只有两个孩子…
当您导入库时,请确保使用自定义视图的名称,它必须匹配,检查