我正在嘗試使用Android Bootstrap庫。我遵循快速入門。在快速啓動,它說我應該重寫我的課是這樣的:如何使用AndroidBootstrap無需擴展應用程序
public class SampleApplication extends Application {
@Override public void onCreate() {
super.onCreate();
TypefaceProvider.registerDefaultIconSets();
}
}
我如何使用這個庫不延長Application
類?我想在我的Activity類中使用這個庫。
LoginActivity:
public class Login extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TypefaceProvider.registerDefaultIconSets();
setContentView(R.layout.activity_login);
}
}
activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<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="com.example.merve.tev.Login">
<com.beardedhen.androidbootstrap.BootstrapDropDown
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:bootstrapText="Medium {fa_thumbs_o_up}"
app:bootstrapBrand="regular"
app:roundedCorners="true"
app:bootstrapSize="md"
app:dropdownResource="@array/bootstrap_dropdown_example_data"
app:bootstrapExpandDirection="down"
tools:layout_editor_absoluteY="202dp"
tools:layout_editor_absoluteX="115dp" />
</LinearLayout>
在我的MainActivity類別,我把按鈕。當我點擊它時,我應該去LoginActivity類。但是,我得到一個錯誤:
java.lang.RuntimeException: Unable to start activity ComponentInfo: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class com.beardedhen.androidbootstrap.BootstrapDropDown
感謝您的快速回復。我試着說你的話。但是現在,我得到一個錯誤:java.lang.RuntimeException:無法啓動活動ComponentInfo。我將我的代碼添加到了我的問題中。 – heyaa
請參閱已更新的答案 – Naimatullah
我嘗試了您的更新答案,它適用於除下拉菜單外的所有內容。謝謝! – heyaa