Questions tagged «android»

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

8
如何为Android应用程序创建透明的演示屏幕?
我正在尝试创建一个半透明的演示屏幕,该屏幕仅在用户首次安装我的应用程序时启动。这是Pulse News应用的示例: Galaxy Nexus Nexus One 我希望用户能够浏览几个这样的透明演示页面,而不是“轻按一下”功能。 第一次尝试时,我修改了ViewPagerIndicator库中的示例。我在每个视图分页器片段的ImageViews中使用了半透明的PNG。然后,在“主活动”的onCreate方法中将其作为“演示活动”启动。 问题:在后台看不到“主要活动”-而是黑色。我在这里尝试了解决方案,但是并没有解决问题。 有没有更好的方法来创建这样的东西,还是我走在正确的轨道上? 我还有另一个相关的问题,这取决于如何实现。我正在尝试覆盖文本和箭头,以便它们指向背景中的特定UI组件。通过使用带有文本和箭头的PNG,很可能在不同设备上无法正确缩放。即,箭头可能不一定指向背景中的正确UI组件。有没有办法解决这个问题呢? 谢谢! 这是我第一次尝试的代码: DemoActivity.java public class DemoActivity extends FragmentActivity { DemoFragmentAdapter mAdapter; ViewPager mPager; PageIndicator mIndicator; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.demo_activity); mAdapter = new DemoFragmentAdapter(getSupportFragmentManager()); mPager = (ViewPager)findViewById(R.id.pager); mPager.setAdapter(mAdapter); //mPager.setAlpha(0); UnderlinePageIndicator indicator = (UnderlinePageIndicator)findViewById(R.id.indicator); indicator.setViewPager(mPager); indicator.setFades(false); mIndicator …

6
Adb设备找不到我的电话
关闭。这个问题是题外话。它当前不接受答案。 想改善这个问题吗? 更新问题,使其成为Stack Overflow 的主题。 7年前关闭。 改善这个问题 我正在尝试让adb查看我的Samsung Fascinate手机,以便可以通过USB将我的Android应用安装到手机上。我正在使用osx 10.6.7。 当我运行“ adb设备”时,它不会列出我的设备,而“ adb usb”则显示“找不到设备”。 USB调试已启用,我尝试以存储模式和媒体模式进行连接。当我处于存储模式时,可以在Finder中看到手机的驱动器,因此我知道USB连接有效,但是adb仍然找不到它。 我读到Mac上没有USB驱动程序,只是应该可以使用,但事实并非如此。 有什么建议?
105 android  adb 

1
向Android添加新的网络载体
我想将新的承载添加到Android(rooted / custom build),以便与Wifi和GPRS保持对等。 我已经完成了一些Android开发,并且我知道(在Android 2.2中)WIFI和GPRS都有常量。这是否意味着我需要在各处添加常量,并提供网络堆栈? 我要添加的第一个载体是USBNet(适用于具有USB主机的Android)。 另一个将是作为第二个GPRS承载的3G USB加密狗。 我已经开始下载源代码了。

17
Android依赖项的编译和运行时版本不同
将Android Studio从Canary 3更新到Canary 4后,在构建时会引发以下错误。 Android依赖项'com.android.support:support-support-v4'对于编译(25.2.0)和运行时(26.0.0-beta2)类路径具有不同的版本。您应该通过DependencyResolution手动设置相同的版本。 我在整个项目中进行了一次完整的搜索,25.1.0没有使用该版本。 App-build.gradle android { compileSdkVersion 26 buildToolsVersion '26.0.0' defaultConfig { applicationId "com.xxx.xxxx" minSdkVersion 14 targetSdkVersion versionCode 1 versionName "1.0" multiDexEnabled true } buildTypes { debug { debuggable true } release { debuggable false minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } lintOptions { abortOnError false …

6
将波纹效果添加到RecyclerView项目
我正在尝试将波纹效果添加到RecyclerView的项目中。我在网上看了一下,但找不到我需要的东西。我认为它必须是自定义效果。我已经尝试将android:background属性设置为RecyclerView本身,并将其设置为“?android:selectableItemBackground”,但是它不起作用。 <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="true" android:clickable="true" android:background="?android:selectableItemBackground" android:id="@+id/recyclerView" android:layout_below="@+id/tool_bar"/> 这是我要在其中添加效果的RecyclerView:

6
有什么方法可以在代码中为RecyclerView启用滚动条吗?
如我们所见,RecyclerView比ListView更有效,因此我更喜欢在项目中使用它。但是最近,将其放入自定义ViewGroup时遇到了麻烦。RecyclerView易于在xml中设置滚动条,如下所示: <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent" /> 但是我真的找不到任何方法来在RecyclerView的代码中设置滚动条,我尝试过的是: mRecyclerView.setVerticalScrollBarEnabled(true); 然后我在Android的文档中看到了这一点。 因此,我尝试制作自己的LayoutManager并覆盖我认为自己需要的功能。但是最后我失败了。因此,谁能告诉我如何制作自己的LayoutManager或仅向我展示其他解决方案。谢谢!

11
在Android中共享应用程序“链接”
我希望我的应用程序用户能够与其他用户共享/推荐我的应用程序。我使用ACTION_SEND意图。我添加纯文本,其中包含以下内容:安装此炫酷应用程序。但是我找不到能使用户直接进入市场安装屏幕的方法。我所能提供的只是一个Web链接或一些文本。换句话说,我正在寻找一种非常直接的方式来让android用户安装我的应用。 感谢您的帮助/指标, 汤玛士
105 android  share 

2
Android onCreate或onStartCommand用于启动服务
通常,当我创建Android服务时,会实现该onCreate方法,但是在我的上一个项目中,此方法不起作用。我尝试实施onStartCommand,这似乎可行。 问题是:何时必须实施服务,需要哪种方法?我必须实现哪些方法?onCreate,onStartCommand或两者兼而有之?每个角色扮演什么角色?

7
AndroidX:Appcompat I:艺术错误android.view.View $ OnUnhandledKeyEventListener
在一个使用Androidx:appcompat:appcompat:1.0.0-rc01新建的项目中, java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList 我还添加了configuration.all configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == "androidx.appcompat") { if (!requested.name.startsWith("multidex")) { details.useVersion "1.+" } } } } 这不影响应用程序功能或崩溃。但是在应用程序运行时始终会出现此错误。请帮助我解决错误。整个堆栈跟踪如下。 I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener; I/art: at …
105 android  androidx 

10
使用JsonReader.setLenient(true)在第1行第1列路径$处接受格式错误的JSON
这是什么错误?我怎样才能解决这个问题?我的应用程序正在运行,但无法加载数据。这是我的错误:使用JsonReader.setLenient(true)在第1行第1列路径$接受格式错误的JSON 这是我的片段: public class news extends Fragment { private RecyclerView recyclerView; private ArrayList<Deatails> data; private DataAdapter adapter; private View myFragmentView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { myFragmentView = inflater.inflate(R.layout.news, container, false); initViews(); return myFragmentView; } private void initViews() { recyclerView = (RecyclerView) myFragmentView.findViewById(R.id.card_recycler_view); RecyclerView.LayoutManager layoutManager = …
105 android  json  gson  retrofit 

7
Android ConstraintLayout-将一个视图放在另一个视图之上
我正在尝试ProgressBar在上方添加一个Button(两者都在内ConstraintLayout)。 <Button android:id="@+id/sign_in_button" android:layout_width="280dp" android:layout_height="75dp" android:layout_marginBottom="75dp" android:layout_marginTop="50dp" android:text="@string/sign_in" android:textColor="@color/white" android:textSize="22sp" android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/passwordEditText" app:layout_constraintVertical_bias="0.0"/> <ProgressBar android:id="@+id/progressBar" style="?android:attr/progressBarStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="@+id/sign_in_button" android:layout_marginTop="8dp" app:layout_constraintBottom_toBottomOf="@+id/sign_in_button" android:layout_marginBottom="8dp" app:layout_constraintVertical_bias="0.5" android:layout_marginLeft="8dp" app:layout_constraintLeft_toLeftOf="@+id/sign_in_button" android:layout_marginRight="8dp" app:layout_constraintRight_toRightOf="@+id/sign_in_button"/> 但即使打完电话后bringToFront上ProgressBar的onCreate,它总是背后的支柱Button。 ProgressBar progressBar = (ProgressBar)findViewById(R.id.progressBar); progressBar.bringToFront();

7
MutableLiveData中的setValue()和postValue()的区别
有两种方法可以使的变化值MutableLiveData。但是setValue()&postValue()in 之间有什么区别MutableLiveData。 我找不到相同的文档。 这是MutableLiveDataAndroid 类。 package android.arch.lifecycle; /** * {@link LiveData} which publicly exposes {@link #setValue(T)} and {@link #postValue(T)} method. * * @param <T> The type of data hold by this instance */ @SuppressWarnings("WeakerAccess") public class MutableLiveData<T> extends LiveData<T> { @Override public void postValue(T value) { super.postValue(value); } @Override public …

3
Android Room-使用LIKE选择查询
我正在尝试查询所有名称包含文本的对象: @Query("SELECT * FROM hamster WHERE name LIKE %:arg0%") fun loadHamsters(search: String?): Flowable<List<Hamster>> 讯息: Error:no viable alternative at input 'SELECT * FROM hamster WHERE name LIKE %' Error:There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (near "%": syntax error) Error:Unused parameter: arg0 我也在尝试: @Query("SELECT * …

17
如何解决此CrashlyticsMissingDependencyException?
我一直在使用最新的Crashlytics(Fabric集成)。但是最近我由于缺少依赖性而遇到了以下崩溃错误,尽管我没有对Crashlytics配置进行任何更改。 任何想法? 02-08 22:18:00.935 18887-18887/? E/Fabric﹕ . 02-08 22:18:00.935 18887-18887/? E/Fabric﹕ . | | 02-08 22:18:00.935 18887-18887/? E/Fabric﹕ . | | 02-08 22:18:00.935 18887-18887/? E/Fabric﹕ . | | 02-08 22:18:00.935 18887-18887/? E/Fabric﹕ . \ | | / 02-08 22:18:00.935 18887-18887/? E/Fabric﹕ . \ / 02-08 22:18:00.935 18887-18887/? E/Fabric﹕ . \ …

16
片段不会被替换,而是放在前一个之上
活动: FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); Fragment1 fragment = new Fragment1(); Fragment2 fragment2 = new Fragment2(); transaction.replace(R.id.Fragment1, fragment); transaction.addToBackStack(null); transaction.commit(); FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction(); transaction2.replace(R.id.Fragment1, fragment2); transaction2.addToBackStack(null); transaction2.commit(); 视图中的代码: <fragment android:id="@+id/Fragment1" android:name="com.landa.fragment.Fragment1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_below="@+id/include1" /> 问题是,内容并没有真正被替换-它被放在顶部(因此重叠)。 当我单击返回时,第一个片段正确显示(没有第二个片段),但是最初两个片段都是可见的(我只希望最后一个片段可见)。 我在这里想念什么?

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.