小编Tob*_*ias的帖子

min SDK版本/目标SDK版本与编译SDK版本有什么区别?

"min sdk version/target sdk version"和"compile sdk version"有什么区别?我知道min和target sdk意味着什么,但是编译sdk版本意味着什么?

在Eclipse中,我有min/max和target sdk,但在android studio中有这三个设置.

android android-studio

194
推荐指数
6
解决办法
9万
查看次数

Android DrawerLayout - 没有重力抽屉视图

当我点击我的抽屉切换时,我得到以下异常

java.lang.IllegalArgumentException:在重力下没有找到抽屉视图

这是我的activity_drawer.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"/>

    <FrameLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <fragment
        android:id="@+id/navigation"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:name="com.xyz.ui.navigation.NavigationFragment"
        tools:layout="@layout/fragment_navigation" />

    </LinearLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

我的fragment_navigation.xml

<?xml version="1.0" encoding="utf-8"?>
<ListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start">

</ListView>
Run Code Online (Sandbox Code Playgroud)

还有我的清单项目

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Large Text"
        android:id="@+id/navigation_item_text"
        android:layout_gravity="center_horizontal" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android navigation-drawer

31
推荐指数
3
解决办法
4万
查看次数

无法在onLoadFinished中执行此操作

我正在创建一个带有一个活动和许多片段的新示例Android应用程序.

起初我正在启动"OverviewFragment"(我的仪表板),它应该显示一些基本信息.我的OverviewFragment使用"AccountProvider"(ContentProvider)加载信息.如果数据库为空,则应将OverviewFragment替换为我的WelcomeFragment ...

这是一些代码:

public class OverviewFragment extends BaseFragment
    implements LoaderManager.LoaderCallbacks {

private static final int LOADER_ACCOUNTS = 10;
private static final int LOADER_TRANSACTIONS = 20;

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    getLoaderManager().initLoader(LOADER_ACCOUNTS, null, this);
    //getLoaderManager().initLoader(LOADER_TRANSACTIONS, null, this);
}

@Override
public Loader onCreateLoader(int id, Bundle args) {
    Uri uri = null;
    String[] projection = null;
    String selection = null;
    String[] selectionArgs = null;
    String sortOrder = null;

    switch (id) {
        case LOADER_ACCOUNTS:
            uri = WalletProvider.CONTENT_URI;
            projection = new String[]{DBHelper.ACC_ID, …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

19
推荐指数
2
解决办法
7662
查看次数

Android Studio:意外的顶级异常(以非零退出值2完成..)

当我试图调试我的Android应用程序时,我收到以下错误消息:

错误:任务':app:transformClassesWithDexForDebug'的执行失败.

com.android.build.transform.api.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_31. jdk/Contents/Home/bin/java''以非零退出值2结束

该错误首先出现在添加新依赖项上.这是我的gradle文件

compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.google.dagger:dagger:2.0.1'
apt 'com.google.dagger:dagger-compiler:2.0.1'
provided 'javax.annotation:jsr250-api:1.0'

compile 'com.jakewharton:butterknife:7.0.1'
compile 'de.greenrobot:eventbus:2.4.0'
// Icepick
compile 'frankiesardo:icepick:3.1.0'
provided 'frankiesardo:icepick-processor:3.1.0'
// Mosby
compile 'com.hannesdorfmann.mosby:mvp:2.0.0'
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.1'
apt 'com.hannesdorfmann.parcelableplease:processor:1.0.1'

compile 'com.ogaclejapan.smarttablayout:library:1.4.2@aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.4.2@aar'
compile 'com.ogaclejapan.smarttablayout:utils-v13:1.4.2@aar'
Run Code Online (Sandbox Code Playgroud)

当我尝试使用smarttablayout时出现错误.使用gradle 1.4版本.有人知道出了什么问题吗?

android android-gradle-plugin

10
推荐指数
1
解决办法
9897
查看次数

一项活动 - 许多片段或许多活动 - 许多片段?

我正在计划一个带导航抽屉的新应用程序.最好使用一个管理许多片段的活动,或者使用许多片段的许多活动?有什么严重的优点或缺点吗?

我读了很多关于这个的文章,但是从2012年开始到现在.

(我只是计划阅读并在数据库中插入一些数据..)

android android-fragments

6
推荐指数
1
解决办法
3533
查看次数

Dagger2错误:没有@Inject构造函数就无法提供

我对Dagger 2全新,并且遇到一个小问题.希望你能帮助我:)我的android项目中有以下类

  1. 应用
  2. AppComponent
  3. 的AppModule
  4. 主要活动
  5. MainComponent
  6. MainModule
  7. IntentStarter

在重建/编译时我得到错误

Error:(15, 10) error: xyz.IntentStarter cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method.
xyz..MainActivity.intentStarter
[injected field of type: xyz..IntentStarter intentStarter]
Run Code Online (Sandbox Code Playgroud)

我尝试了很多变种但没有成功......我在IntentStarter类中使用构造函数尝试了它..没有构造函数......:/现在有些代码......

// AppComponent.class
@Singleton
@Component(modules = {AppModule.class})
public interface AppComponent {
// Empty...
}
Run Code Online (Sandbox Code Playgroud)

...

// AppModule.class
@Singleton
@Module
public class AppModule {

    Application application;
    Context context;


    public AppModule(Application app) {
        this.application = app;
        this.context = app.getApplicationContext();
    }


    @Provides
    public Application provideApplication() {
        return application; …
Run Code Online (Sandbox Code Playgroud)

android dependency-injection dagger-2

5
推荐指数
1
解决办法
7480
查看次数

在文件流上应用模式

public final Pattern PATTERN = Pattern.compile("<abc:c\\sabc:name=\"(\\S+)\"\\sabc:type=\"(\\S+)\">");
    try (Stream<String> stream = Files.lines(template.getPath())) {
        stream.filter(s -> PATTERN.matcher(s).find()).forEach(System.out::println);

    } catch (IOException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

该模式工作正常,但我如何捕获/获取我的组?目前我只得到弦乐.

java lambda java-8

5
推荐指数
1
解决办法
142
查看次数

Excel VBA - FormatConditions

我想在我的应用程序中使用以下vba代码

.FormatConditions.Add Type:=xlExpression, Formula1:="=Mod(Column(), 2)"
Run Code Online (Sandbox Code Playgroud)

我收到了一个错误

错误编号5.无效参数

这段代码出了什么问题?谢谢

这是我在我的子代码中的完整代码..所有FomatConditions工作正常 - 除了最后两个..

    ' FormatConditions
With Range("K6:BH" & lastUsedRow)
    .FormatConditions.Delete
    ' Prozent
    .FormatConditions.Add Type:=xlExpression, Formula1:="=Prozent"
    .FormatConditions(1).StopIfTrue = False
    .FormatConditions(1).Interior.Pattern = xlNone
    .FormatConditions(1).Interior.Color = RGB(174, 170, 170)
    With .FormatConditions(1).Borders(xlBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 2
        .Weight = xlThin
    End With
    ' Prozent unter
    .FormatConditions.Add Type:=xlExpression, Formula1:="=ProzentUnter"
    .FormatConditions(2).StopIfTrue = False
    .FormatConditions(2).Interior.Color = RGB(255, 192, 0)
    With .FormatConditions(2).Borders(xlBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 2
        .Weight = xlThin
    End With
    ' ist
    .FormatConditions.Add Type:=xlExpression, Formula1:="=Ist"
    .FormatConditions(3).StopIfTrue …
Run Code Online (Sandbox Code Playgroud)

excel vba excel-vba

3
推荐指数
1
解决办法
5282
查看次数

Android Studio - Gradle构建的日志文件

我正在使用Android Studio版本1.1.0,每次我想构建我的应用程序时,Android Studio都会冻结.我必须通过我的任务管理器关闭程序.

我知道Gradle很内疚,但我无法阅读Gradle构建消息.在任何地方都有日志文件吗?我找不到东西.我是OS X用户.谢谢.

android-studio

3
推荐指数
1
解决办法
5212
查看次数