Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。

19
在Android Studio中添加外部库
我想向我的Android应用程序添加外部库https://github.com/foursquare/foursquare-android-oauth(我使用Android Studio,lib作者提供的针对Eclipse的说明不适用于Android Studio)。 我试图用Maven做到这一点,所以我在File-> Project Structure-> Dependencies中添加了,com.foursquare:foursquare-android-nativeoauth-lib:1.0.0但是Gradle Sync失败了: Error:Failed to find: com.foursquare:foursquare-android-nativeoauth-lib:1.0.0 当我尝试构建我的应用程序时(由于无法解决以上错误,我不知道如何解决),我得到: Error:A problem occurred configuring project ':app'. > Could not resolve all dependencies for configuration ':app:_debugCompile'. > Could not resolve com.foursquare:foursquare-android-nativeoauth-lib:1.0.0. Required by: ForSquaresOnly:app:unspecified > Could not parse POM http://jcenter.bintray.com/com/foursquare/foursquare-android-nativeoauth-lib/1.0.0/foursquare-android-nativeoauth-lib-1.0.0.pom > Could not find any version that matches …

10
使用TabLayout时如何更改标签的背景色?
这是我主要活动中的代码 public class FilterActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_filter); // Get the ViewPager and set it's PagerAdapter so that it can display items ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); PageAdapter pageAdapter = new PageAdapter(getSupportFragmentManager(), FilterActivity.this); viewPager.setAdapter(pageAdapter); // Give the TabLayout the ViewPager final TabLayout tabLayout …

16
如何设置新工具栏的标题颜色?
我使用的是新的v7工具栏,我一生都无法确定如何更改标题的颜色。我已经将工具栏的@style设置为在styles.xml中声明的样式,并应用了带有textColor的titleTextStyle。我想念什么吗?我正在为棒棒糖编码,但目前正在Kitkat设备上进行测试。 styles.xml <resources> <!-- Base application theme. --> <style name="AppTheme" parent="@style/Theme.AppCompat.Light"> <item name="android:windowNoTitle">true</item> <item name="windowActionBar">false</item> </style> <style name="ActionBar" parent="Theme.AppCompat"> <item name="android:background">@color/actionbar_background</item> <item name="android:titleTextStyle">@style/ActionBar.TitleTextStyle</item> </style> <style name="ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"> <item name="android:textColor">@color/actionbar_title_text</item> </style> </resources> actionbar.xml: <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar_actionbar" android:layout_width="match_parent" android:layout_height="?actionBarSize" style="@style/ActionBar"/>
119 android  themes  toolbar 

17
Android:从后堆栈中删除所有先前的活动
当我单击“ 个人资料活动”中的“ 注销”按钮时,我想让用户进入“ 登录”页面,他需要在其中使用新的凭据。 因此,我使用此代码: Intent intent = new Intent(ProfileActivity.this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); 在“ onButtonClick注销”按钮的中。 但是问题是,当我单击登录活动上的设备后退按钮时,它将带我到ProfileActivity。我期望当我在LoginActivity上按设备后退按钮时,应用程序应该关闭。 我究竟做错了什么? 我还android:launchMode="singleTop"为我的LoginActivity添加了清单 谢谢


4
如果多次启动Android服务会怎样?
如果我有以下代码: Intent intent = new Intent(this,DownloadService.class); for(int i=0;i<filesArray.length;i++){ startService(intent); } 在此代码中DownloadService扩展IntentService。 因此,现在当我打电话时startService(intent),这意味着我每次都在启动一个新服务,startService(intent)或者这意味着它DownloadService要运行一次,然后每次我调用startService(intent)它时,都会传递具有不同startId的不同意图。 这有意义吗?是哪种情况?
119 android 

8
Android Studio:如何在运行或调试之前自动卸载APK(或执行adb命令)?
现在,我需要Run\Debug在Android Studio中每次都卸载该应用程序。因为我需要在运行\ debug应用程序之前重新创建数据库。我知道我可以运行命令 adb uninstall [package_name] 在终端中清除下的文件/data/data/[package_name]。但这不是我每次必须执行命令的便捷方法。我希望 adb uninstall 单击Run\Debug按钮可以自动执行命令。

2
src / androidtest和src / test文件夹有什么区别?
在一个项目中,默认情况下,在Android Studio中有两个测试文件夹。 首先是src/androidTest。此文件夹在先前版本的Android Studio中已经存在。不过,现在有一个新的测试文件夹,默认情况下src/test,新的依赖,testCompile 'junit: junit: 4.12'在build.gradle。 我使用哪个文件夹进行测试?两者之间有什么区别?



22
Android Studio-如何增加分配的堆大小
我使用Android Studio已有3个月了,而我开始使用它的应用程序已经变得相当庞大。程序右下角指示的内存使用量表示我分配的堆最大为494M。 当我开始更改XML文件时,我的内存使用量很快达到该上限,并且IDE崩溃,并显示如下内存不足错误。 我尝试使用此方法来增加堆大小,但到目前为止没有任何效果。 我看了很多关于如何增加堆大小的文章和其他问题,但是他们的答案都没有用。无论我对VMOPTIONS或IDE设置做什么,堆大小都不会增加。我相信我正在为VMOPTIONS编辑正确的文件,因为如果我故意给它一个无效的命令,Android Studio会抱怨它并且无法启动。 我正在使用Windows 7-64位并具有16GB RAM。还有其他人在Android Studio中遇到此问题吗?并且您能够修复它?

19
在Android Studio和Gradle中使用ViewPagerIndicator库
我正在尝试使用Jake Wharton的ViewPagerIndicator库,但无法使其与Android Studio中的Gradle项目一起使用。 我将其添加为依赖项,如下所示: dependencies { // ... other ommitted compile 'com.viewpagerindicator:library:2.4.1' compile 'com.android.support:support-v4:19.0.1' compile 'com.nineoldandroids:library:2.4.0' // ... } 但是该项目似乎无法识别库中的任何组件。我想知道不同的support-v4版本是否存在依赖性问题,或者是否在nineoldandroids中出现问题...?

17
Android:如何在保持宽高比的同时将图像拉伸到屏幕宽度?
我想下载一个图像(大小不明,但始终大致为正方形)并显示它,以便它在任何屏幕尺寸上都水平填充屏幕,并垂直拉伸以保持图像的纵横比。这是我的代码(无效)。它水平拉伸图像,但不垂直拉伸图像,因此被压缩... ImageView mainImageView = new ImageView(context); mainImageView.setImageBitmap(mainImage); //downloaded from server mainImageView.setScaleType(ScaleType.FIT_XY); //mainImageView.setAdjustViewBounds(true); //with this line enabled, just scales image down addView(mainImageView,new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
118 java  android  layout 



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.