当我试图运行我的应用程序并且不知道如何修复它时,我遇到了这些问题...
有人请帮帮我
这是错误:
[2014-04-18 18:47:35 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v7/app/ActionBar$Callback;
[2014-04-18 18:47:35 - CQUdiary] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v7/app/ActionBar$Callback;
Run Code Online (Sandbox Code Playgroud) 我升级到avtionbar app compat v21进行材料设计.
但我观察到它没有在操作栏和导航菜单和后退按钮中显示应用程序图标,与旧的appcompat库相比占用更多空间.
有人遇到过这个问题吗?我搜索了很多,但没有找到任何有用的东西.
下面的行也没有用.
getSupportActionBar().setLogo(R.drawable.ic_launcher);
Run Code Online (Sandbox Code Playgroud)
我正在使用动作栏的样式
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:icon">@drawable/ic_action_bar</item>
<item name="android:background">@drawable/action_bar_bg</item>
<item name="android:windowContentOverlay">@null</item>
<!-- Support library compatibility -->
<item name="background">@drawable/action_bar_bg</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我知道其他解决方案,如工具栏.但是我处于发布阶段,由于时间限制,我正在寻找一些快速解决方案(如果有的话).添加工具栏需要更多时间.
我从普通的ActionBar更改为新的工具栏.我的问题是我的旧菜单不起作用.当我点击溢出图标时没有任何反应.我正在使用appcompat v7,但我找不到任何解决方案.有人能帮我吗?
Menufunctions:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu
getMenuInflater().inflate(R.menu.chatmenu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.onlineliste:
getOnlineList();
return true;
case R.id.settings:
showSettings();
return true;
case R.id.logout:
logout();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Run Code Online (Sandbox Code Playgroud)
Chatmenu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/onlineliste"
android:title="@string/userliste"
app:showAsAction="always">
</item>
<item
android:id="@+id/settings"
android:title="@string/settings"
app:showAsAction="never">
</item>
<item
android:id="@+id/logout"
android:title="@string/logout"
app:showAsAction="never">
</item>
</menu>
Run Code Online (Sandbox Code Playgroud)
主题
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#428bca</item>
<item name="colorPrimaryDark">#428bca</item>
<item …Run Code Online (Sandbox Code Playgroud) 我一直在尝试按照这些说明实现Material Design主题.
ToolBar(我必须吗?)getSupportActionBar()整个项目.<application>标签包含android:theme="@style/AppTheme"我的styles.xml:
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="displayOptions">useLogo|showHome</item>
<item name="logo">@drawable/home_page_logo</item>
<item name="background">@color/actionbar_background_color</item>
<item name="textColor">@color/white</item>
<item name="titleTextStyle">@style/MyActionBarTextStyle</item>
</style>
Run Code Online (Sandbox Code Playgroud)
无论我尝试了什么,应用程序崩溃第二次我onCreate()使用此崩溃日志启动我的主要活动:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中添加导航抽屉.这是代码:
<DrawerLayout 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="com.example.abcxyz.properprojectdb.MyDrawerActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
<ListView
android:layout_width="240dp"
android:layout_height="match_parent"
android:id="@+id/listView"
android:entries="@array/planets"></ListView>
</DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我无法为ListView添加属性android:layout_gravity.我不知道它为什么不能使用(intellisense工作得很好,但它不会显示layout_gravity)
我运行时我的应用程序崩溃,但如果我用LinearLayout替换DrawerLayout,应用程序不会崩溃.我猜这是因为我没有为ListView添加属性android:layout_gravity.
这是一个快照,显示layout_gravity也没有出现在intellisense中
android listview android-appcompat layout-gravity navigation-drawer
我更新AppCompat到新发布的版本22.1.0并将我更改AlertDialog为support.v7.app.AlertDialog.但是在Lollipop设备上,它会抛出以下异常dismissDialog().
java.lang.NullPointerException: attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
at android.support.v7.internal.app.WindowDecorActionBar.getDecorToolbar(WindowDecorActionBar.java:248)
at android.support.v7.internal.app.WindowDecorActionBar.init(WindowDecorActionBar.java:201)
at android.support.v7.internal.app.WindowDecorActionBar.<init>(WindowDecorActionBar.java:184)
at android.support.v7.app.AppCompatDeleg ateImplV7.cre ateSupportActionBar(AppCompatDelegateImplV7.java:176)
at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:85)
at android.support.v7.app.AppCompatDelegateImplV7.onStop(AppCompatDeleg ateImplV7.java:221)
at android.support.v7.app.AppCompatDialog.onStop(AppCompatDialog.java:108)
at android.app.Dialog.dismissDialog(Dialog.java:438)
at android.app.Dialog.dismiss(Dialog.java:414)
at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:157)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Run Code Online (Sandbox Code Playgroud)
我如何解决它?
(较低版本的设备似乎运行良好.这只发生在Lollipop)
+
我没有dismiss()在我的代码中明确调用.当按钮被后退按钮或正/负按钮关闭时,该对话框将抛出异常.
++这是我使用v7.app.AlertDialog的代码.谢谢.
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.support.v4.app.DialogFragment; …Run Code Online (Sandbox Code Playgroud) 我有的是res/layout/toolbar.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:elevation="4dp"
style="@style/ToolbarStyle">
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
这是我对工具栏的使用:
<LinearLayout 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"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我将它包含在任何Activity动作按钮中,并按预期工作,但有一件事按下动作按钮高亮不适合工具栏
有人遇到过这种问题吗?
谢谢
Xamarin我更新到版本4,Forms和2.0版本.在Android上,我使用AppCompat.
我有一个问题.以前,Android键盘导致调整大小视图.现在这不会发生.键盘出现在顶视图上.并且要隐藏所需的元素.
我试过了:
[Activity(WindowSoftInputMode = SoftInput.AdjustResize, Label = "Title", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
ToolbarResource = Resource.Layout.toolbar;
TabLayoutResource = Resource.Layout.tabs;
LoadApplication(new App());
Window.DecorView.SetFitsSystemWindows(true);
}
}
Run Code Online (Sandbox Code Playgroud)
Daylight AppCompat已在本课程中完成:https://blog.xamarin.com/material-design-for-your-xamarin-forms-android-apps/
谢谢.
android-appcompat android-softkeyboard xamarin xamarin.forms
我正在尝试使我的AppCompatActivity的Action Bar透明.我在找东西像这样(从这个程序).
我试过这样做:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
但它唯一能做的就是让观点落后于行动吧.
我该怎么做才能使文本和导航抽屉按钮成为唯一可见的东西?
编辑:这是我的xml布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="my.package.name"
android:id="@+id/relLayout">
<!-- My views are here -->
</RelativeLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud) 我知道通过使用AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);夜间模式可以在一项活动中实施。但是我想要的是-设置中将提供一个选项,用于在应用程序的所有活动和片段中激活夜间模式。我怎样才能做到这一点?