gpt4 book ai didi

java - SlidingUpPanel 崩溃

转载 作者:行者123 更新时间:2023-11-29 21:08:17 28 4
gpt4 key购买 nike

我想使用 Umano/SlidingUpPanel在我的主要 Activity 中

这是我的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();

}

}

当我编译时,代码编译通过,但它崩溃并出现以下错误代码:

05-22 08:57:12.884: E/AndroidRuntime(4126): FATAL EXCEPTION: main 05-22 08:57:12.884: E/AndroidRuntime(4126): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mainpackage/com.mainpackage.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.sothree.slidinguppanel.SlidingUpPanelLayout 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.ActivityThread.access$600(ActivityThread.java:123) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.os.Handler.dispatchMessage(Handler.java:99) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.os.Looper.loop(Looper.java:137) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.ActivityThread.main(ActivityThread.java:4424) 05-22 08:57:12.884: E/AndroidRuntime(4126): at java.lang.reflect.Method.invokeNative(Native Method) 05-22 08:57:12.884: E/AndroidRuntime(4126): at java.lang.reflect.Method.invoke(Method.java:511) 05-22 08:57:12.884: E/AndroidRuntime(4126): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825) 05-22 08:57:12.884: E/AndroidRuntime(4126): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:592) 05-22 08:57:12.884: E/AndroidRuntime(4126): at dalvik.system.NativeStart.main(Native Method) 05-22 08:57:12.884: E/AndroidRuntime(4126): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.sothree.slidinguppanel.SlidingUpPanelLayout 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 05-22 08:57:12.884: E/AndroidRuntime(4126): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.Activity.setContentView(Activity.java:1835) 05-22 08:57:12.884: E/AndroidRuntime(4126): at com.mainpackage.MainActivity.onCreate(MainActivity.java:26) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.Activity.performCreate(Activity.java:4465) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1051) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920) 05-22 08:57:12.884: E/AndroidRuntime(4126): ... 11 more 05-22 08:57:12.884: E/AndroidRuntime(4126): Caused by: java.lang.ClassNotFoundException: com.sothree.slidinguppanel.SlidingUpPanelLayout 05-22 08:57:12.884: E/AndroidRuntime(4126): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 05-22 08:57:12.884: E/AndroidRuntime(4126): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 05-22 08:57:12.884: E/AndroidRuntime(4126): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.view.LayoutInflater.createView(LayoutInflater.java:552) 05-22 08:57:12.884: E/AndroidRuntime(4126): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)

我做错了什么?

最佳答案

谢谢大家。问题很简单,我没有将图书馆标记为图书馆项目。我这样做了,并将它添加到我自己的项目的构建路径中,并且成功了。

关于java - SlidingUpPanel 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23797596/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com