Questions tagged «android»

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


7
android.content.res.Resources $ NotFoundException:字符串资源ID#0x0
我正在开发一个Android应用,该应用从MySQL数据库读取数据,但遇到了此错误。我有这个XML布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/wardNumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="3dp" android:text="Ward Number" android:textSize="22dp"/> <TextView android:id="@+id/dateTime" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/wardNumber" android:layout_alignParentRight="true" android:layout_marginRight="3dp" android:text="Date-Time" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/dateTime" android:layout_alignBottom="@+id/dateTime" android:layout_alignLeft="@+id/wardNumber" android:layout_marginLeft="3dp" android:text="Name" /> </RelativeLayout> 这是我的Java文件: public ApplicationAdapter(Context context, List<Application> items) { super(context, R.layout.app_custom_list, items); this.items = …
145 java  android  xml  listview 

8
如何使用String类型生成buildConfigField
在我的Android Studio项目中有两个build configuration与一些buildConfigField: buildTypes { def SERVER_URL = "SERVER_URL" def APP_VERSION = "APP_VERSION" debug { buildConfigField "String", SERVER_URL, "http://dev.myserver.com" buildConfigField "String", APP_VERSION, "0.0.1" } release { buildConfigField "String", SERVER_URL, "https://myserver.com" buildConfigField "String", APP_VERSION, "0.0.1" minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } 我得到和错误如下: /path/to/generated/BuildConfig.java Error:(14, 47) error: ';' expected Error:(15, 47) …

20
有意图地启动短信应用程序
我对意图有疑问...我尝试启动短信应用... Intent intent = new Intent(Intent.ACTION_MAIN); intent.setType("vnd.android-dir/mms-sms"); int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP; intent.setFlags(flags); intent.setData(Uri.parse("content://sms/inbox")); context.startActivity(intent); 因此,您可以看到我的意图太多了,但这是因为我不知道该怎么做...谢谢

2
在ScrollView中查看并不是全部
我在ScrollView中有一个RelativeLayout。我的RelativeLayout有,android:layout_height="match_parent"但是视图没有占据整个大小,就像wrap_content一样。 有没有办法实现真正​​的fill_parent / match_parent行为? 我的布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/top" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:scaleType="fitXY" android:src="@drawable/top" /> <ImageView android:id="@+id/header" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/top" android:scaleType="fitXY" android:src="@drawable/headerbig" /> <ImageView android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/header" android:layout_centerHorizontal="true" android:layout_marginBottom="3dp" android:src="@drawable/logo" /> <ScrollView android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_above="@+id/bottom" android:layout_below="@+id/logo" android:background="@drawable/background" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/dashboard01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/dashboard02" android:layout_centerHorizontal="true" …

13
Android-startActivityForResult立即触发onActivityResult
我正在使用call从我的应用程序中的主要活动中启动活动startActivityForResult(intent, ACTIVITY_TYPE),而所有活动都只有一个活动。 调用该onActivityResult()函数后,将根据需要启动该活动,但是在日志中,我可以看到它立即被触发。活动显示,但RESULT_CANCELED立即返回onActivityResult()。 然后,我与互动活动,按该呼叫的按钮finish(),并且onActivityResult()不叫这个时候(因为很明显的结果已经返回)。 这对任何人有意义吗?有人见过这种行为吗?

25
错误:在包“ com.google.example” main.xml中找不到属性“ adSize”的资源标识符
当我按照说明通过xml将广告添加到我的应用程序时,出现以下错误: Description Resource Path Location Type error: No resource identifier found for attribute 'adSize' in package 'com.google.example' main.xml /HelloWorld/res/layout line 12 Android AAPT Problem Description Resource Path Location Type error: No resource identifier found for attribute 'adUnitId' in package 'com.google.example' main.xml /HelloWorld/res/layout line 12 Android AAPT Problem 我确实编辑了main.xml添加attrs.xml文件,但编译器不喜欢它。
144 android  admob 



8
错误::在打包APK期间重复文件
Android Studio。在应用程序运行期间出现这种错误。 Error:Execution failed for task ':app:packageDebug'. Duplicate files copied in APK META-INF/notice.txt build.gradle apply plugin: 'android' android { compileSdkVersion 19 buildToolsVersion "19.0.1" packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/ASL2.0' } defaultConfig { minSdkVersion 7 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes …

10
Android Facebook 4.0 SDK如何获取电子邮件,用户的出生日期和性别
我正在使用以下代码。我想要用户的出生日期,电子邮件和性别。请帮忙。如何检索这些数据? 这是我onViewCreated()里面的碎片。 @Override public void onViewCreated(View view, Bundle savedInstanceState) { // Setup TextView. mTextDetails = (TextView) view.findViewById(R.id.text_details); // Set up Login Button. LoginButton mButtonLogin = (LoginButton) view.findViewById(R.id.login_button); // setFragment only if you are using it inside a Fragment. mButtonLogin.setFragment(this); mButtonLogin.setReadPermissions("user_friends"); mButtonLogin.setReadPermissions("public_profile"); mButtonLogin.setReadPermissions("email"); mButtonLogin.setReadPermissions("user_birthday"); // Register a callback method when Login …

4
如何使用Android Studio和Gradle构建android库?
我正在尝试从Eclipse迁移项目,但是我没有尝试过。在Eclipse中,我有3个项目(2个android应用程序项目和1个android库项目)。2个应用程序项目取决于库项目。当我执行gradle导出时,我得到3个无效的项目。我愿意对项目进行重组,但没有找到有关如何完成此工作的任何文档。 有没有办法使Eclipse导出的3个项目一起工作?我最好重新组织一下事情,如果可以的话,是否提供有关如何完成此工作的文档? 更新资料 我已将整个项目上传到GitHub https://github.com/respectTheCode/android-studio-library-example 更新1 根据Padma Kumar的建议,这就是我尝试过的方法。 创建一个名为 MyApp 点击File > New Module,选择Android Library并命名MyLib 请点击 Build > Make Project 构建因此错误而失败 Module "MyLib" was fully rebuilt due to project configuration/dependencies changes Compilation completed with 1 error and 0 warnings in 19 sec 1 error 0 warnings /.../MyApp/MyLib/build/bundles/debug/AndroidManifest.xml Gradle: <manifest> does …

14
SwipeRefreshLayout setRefreshing()最初未显示指标
我有一个非常简单的布局,但是当我打电话setRefreshing(true)在onActivityCreated()我的片段,将其最初不显示。 仅在我执行刷新操作时显示。有什么想法为什么它最初没有出现? 片段xml: <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_container" 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"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> </RelativeLayout> </ScrollView> </android.support.v4.widget.SwipeRefreshLayout> 片段代码: public static class LinkDetailsFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener { @InjectView(R.id.swipe_container) SwipeRefreshLayout mSwipeContainer; public static LinkDetailsFragment newInstance(String subreddit, String linkId) { Bundle args = new Bundle(); args.putString(EXTRA_SUBREDDIT, subreddit); args.putString(EXTRA_LINK_ID, linkId); LinkDetailsFragment …

17
Android RecyclerView添加和删除项目
我有一个带有TextView文本框和十字按钮ImageView的RecyclerView。我在recyclerview外面有一个按钮,使十字按钮ImageView可见/不见了。 我想从recylerview中删除一个项目,当该项目十字按钮ImageView被按下时。 我的适配器: public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> implements View.OnClickListener, View.OnLongClickListener { private ArrayList<String> mDataset; private static Context sContext; public MyAdapter(Context context, ArrayList<String> myDataset) { mDataset = myDataset; sContext = context; } @Override public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_text_view, parent, false); ViewHolder holder = new ViewHolder(v); …

7
具有上一页和下一页边界的ViewPager
我正在设计一个包含多个页面的视图。我希望上一页和下一页的边缘显示如下,并用两根手指滑动即可在页面之间切换。 我尝试使用此处ViewPager建议的负页边距,但仅在屏幕上显示边缘之一,而不同时显示。 或者,有什么方法可以将我的视图的一部分放置在屏幕外,然后对其进行动画处理,使其具有ViewPager字体效果。 我应该怎么做?谢谢 !

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.