标签: android

Java/Eclipse - 不再是R文件

我现在在Eclipse上工作了好几个小时,即使在互联网上进行了很多搜索之后,我还没有找到解决我问题的解决方案:我的项目中没有更多的R.java文件.

在刚刚创建或在我的旧项目上,我没有R文件了,我尝试了很多解决方案(卸载,重新安装Eclipse,清理我的项目,检查我的所有XML,修复android工具的问题等等.. .)

请有人告诉我在这种情况下该怎么办?

java eclipse android adt eclipse-adt

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

如何在Android Studio中打开现有的Eclipse项目?

使用Eclipse中的所有现有项目切换到Android Studio.那么这样做的程序是什么.

eclipse android android-studio

34
推荐指数
2
解决办法
6万
查看次数

Buck vs Gradle,Android构建系统的专业和缺点

我目前正在使用ant来构建Android项目,但它并没有为大型项目削减它,并且维护不同的可交付成果正变得很痛苦.

我正在关注的两个替代方案是Facebook的Buck(http://facebook.github.io/buck/)和谷歌支持Android工作室的Gradle(http://tools.android.com/tech-docs/new- build-system/user-guide).

除了尝试一下并阅读他们的报道之外,我想请问Stackoverflow人员您的建议.最好是如果你已经使用了一段时间的工具,还有Buck的奖励积分,因为它没有得到那么多的报道.

重点是

  • 构建速度,特别适用于开发版
  • 来自相同代码库的多个可交付成果
  • 便于使用

我也对其他选择持开放态度.你有什么建议,为什么?

android build gradle buck

34
推荐指数
4
解决办法
1万
查看次数

是否可以使用除listview之外的其他内容作为drawerlayout中的滑动抽屉

我想有例如LinearLayout或者RelativeLayout从屏幕的,而不是一个孤独的左侧滑动ListView.

我试图将使用LinearLayoutandroid:layout_gravity="start"和我在运行时有此错误:

ClassCastException: android.widget.LinearLayout$LayoutParams cannot 
be cast to android.support.v4.widget.DrawerLayout$LayoutParams
Run Code Online (Sandbox Code Playgroud)

这是布局文件:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    >

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

    <LinearLayout 
        android:layout_width="320dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:orientation="vertical">

        <ImageView 
            android:id="@+id/ivwLogo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/video_icon"
        />

        <ListView 
            android:id="@+id/left_drawer"
            android:layout_width="320dp"
            android:layout_height="match_parent"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            android:background="@android:color/white"
        />

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

谢谢

android drawerlayout

34
推荐指数
3
解决办法
2万
查看次数

Android gradle构建和支持库

我有一个项目,使用一些其他库项目(SlidingMenu,ActionbarSherlock),这两个使用Android支持库,在构建时我得到以下内容:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/LoaderManager;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    at com.android.dx.command.dexer.Main.processClass(Main.java:490)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
    at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    at com.android.dx.command.dexer.Main.processOne(Main.java:422)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
    at com.android.dx.command.dexer.Main.run(Main.java:209)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:91)
Run Code Online (Sandbox Code Playgroud)

两个库项目都依赖于支持lib:

dependencies {
    compile files('libs/android-support-v4.jar')
}
Run Code Online (Sandbox Code Playgroud)

android build gradle

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

Play商店Beta测试返回404

我是一名开发人员,当我观看Google IO 2013并了解新的Beta测试功能时,我感到非常激动.因此,我创建了一个Google+社区和一个Google论坛,并将测试人员放在那里(包括我).

Beta测试截图

我们访问https://play.google.com/apps/testing/com.package.stuff时获得的所有内容(开发人员和测试人员) 是:

404

我有什么诡计吗?我真的很想使用这个功能.

我知道有像https://testflightapp.com/这样的替代品,但我宁愿将我的应用程序保存在这个环境中,我可以将Beta apk"推广"到生产阶段,依此类推.

android google-play

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

全宽导航抽屉

我想创建一个全宽导航抽屉.设置layout_widthmatch_parenton @+id/left_drawer的宽度约为屏幕空间的80%.这似乎是标准行为.我一定要重写onMeasure()DrawerLayout

我目前的代码:

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

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/black"
        android:id="@+id/mainFragmentContainer">
    </FrameLayout>

    <include
        android:id="@+id/left_drawer"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        layout="@layout/drawer"/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

谢谢.

android android-layout navigation-drawer drawerlayout

34
推荐指数
5
解决办法
4万
查看次数

它是如何工作的 - requestLocationUpdates()+ LocationRequest/Listener

我是新的Android编码器,我在请求更新我的本地化时遇到问题.

我使用http://developer.android.com/training/location/receive-location-updates.html上的教程.

我的应用程序可以处理异常,正确获取纬度和长度,地理编码器可以处理显示地址.但我只询问一次位置 - 或者当位置发生变化时.我想做一些时间间隔.现在我开始实现教程中的代码,它看起来像这样:

public class MainActivity extends Activity implements 
GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener,
LocationListener {

private static final int MILLISECONDS_PER_SECOND = 1000;

public static final int UPDATE_INTERVAL_IN_SECONDS = 5;
private static final long UPDATE_INTERVAL =
          MILLISECONDS_PER_SECOND * UPDATE_INTERVAL_IN_SECONDS;

private static final int FASTEST_INTERVAL_IN_SECONDS = 1;
private static final long FASTEST_INTERVAL =
          MILLISECONDS_PER_SECOND * FASTEST_INTERVAL_IN_SECONDS;

private TextView tvStatus;
private TextView tvLatitude;
private TextView tvLongitude;

LocationRequest mLocationRequest;
LocationClient mLocationClient;
Location mCurrentLocation;

boolean bNetworkEnabled;
boolean bGPSEnabled;

@Override
protected void onCreate(Bundle savedInstanceState) …
Run Code Online (Sandbox Code Playgroud)

android location updates locationlistener

34
推荐指数
2
解决办法
10万
查看次数

具有128位UUID的startLeScan在本机Android BLE实现上不起作用

我在Nexus 4上新推出的Android 4.3 BLE API上使用startLeScan(新UUID [] {MY_DESIRED_128_BIT_SERVICE_UUID},回调)时遇到问题.

回调就是没有被调用.我仍然可以在日志中看到传入的包:

08-02 15:48:57.985: I/bt-hci(1051): btu_ble_process_adv_pkt
08-02 15:48:58.636: I/bt-hci(1051): BLE HCI(id=62) event = 0x02)
Run Code Online (Sandbox Code Playgroud)

如果我不使用该参数来过滤UUID,它可以工作.我们使用制造商特定的128位UUID作为我们公司的设备.

现在,我们的设备提供的服务比我在阵列中提供的服务更多.但那应该不是问题.

有人面临同样的问题吗?有解决方案吗

编辑

有几个与扫描有关的问题,这个问题只讨论一个问题:如果您还有扫描问题,请先阅读此评论.还要记住,我的设备强加了16位和128位UUID.大多数人都使用BLE标准提供的16位UUID,如Heart rate或Speed and Cadence.

android bluetooth-lowenergy gatt android-4.3-jelly-bean

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

DrawerLayout卡在滑动上

我正在玩DrawerLayout,我遇到了一个问题.基本上有时当我从屏幕边缘滑动时,DrawerLayout会卡住,直到我将手指从屏幕上抬起(参见下面的屏幕截图)

我不确定是什么,我完全按照谷歌sdk的代码示例.有任何想法吗?

截图错误

这是我在FragmentActivity中唯一拥有的东西:

@Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final String[] names =
                getResources().getStringArray(R.array.nav_names);
        ArrayAdapter<String> adapter =
                new ArrayAdapter<String>(
                        getActionBar().getThemedContext(),
                        android.R.layout.simple_list_item_1, names);

        final DrawerLayout drawer =
                (DrawerLayout)findViewById(R.id.drawer_layout);
        final ListView navList =
                (ListView) findViewById(R.id.drawer);
        navList.setAdapter(adapter);
        navList.setOnItemClickListener(new AdapterView.OnItemClickListener()
        {

            @Override
            public void onItemClick(AdapterView<?> parent,
                                    View view, final int pos, long id)
            {
                drawer.setDrawerListener(
                        new DrawerLayout.SimpleDrawerListener()
                        {
                            @Override
                            public void onDrawerClosed(View drawerView)
                            {
                                super.onDrawerClosed(drawerView);

                            }
                        });
                drawer.closeDrawer(navList);
            }
        });

    }
Run Code Online (Sandbox Code Playgroud)

编辑:我正在为此添加赏金,因为这是一个非常古老的问题,即使在今天仍然存在最新的Android-X(此处提供样本).以下是它的外观:

在此输入图像描述

我汇报一下谷歌(这里,后来又在这里),但它并没有帮助.

我在这个帖子上尝试了所有现有的解决方案,但都没有.如果有人有一个很好的解决方法(虽然仍然使用DrawerLayout或扩展它,或类似的东西),请提出一个有效的解决方案.

android navigation-drawer androidx

34
推荐指数
1
解决办法
4227
查看次数