Questions tagged «android»

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

5
使用include标签的Android数据绑定
更新说明: 上面的示例正常工作,因为版本1.0-rc4 解决了需要不必要的变量的问题。 原始问题: 我完全按照文档中的描述进行操作,但不起作用: main.xml: <layout xmlns:andr... <data> </data> <include layout="@layout/buttons"></include> .... button.xml: <layout xmlns:andr...> <data> </data> <Button android:id="@+id/button" ...." /> MyActivity.java: ... binding = DataBindingUtil.inflate... binding.button; ->cannot resolve symbol 'button' 如何获得按钮?

7
作为参考(主题)以编程方式获取颜色值
考虑一下: styles.xml <style name="BlueTheme" parent="@android:style/Theme.Black.NoTitleBar"> <item name="theme_color">@color/theme_color_blue</item> </style> attrs.xml <attr name="theme_color" format="reference" /> color.xml <color name="theme_color_blue">#ff0071d3</color> 因此,主题颜色由主题引用。如何以编程方式获取theme_color(参考)?通常我会使用,getResources().getColor()但在这种情况下不会使用,因为它已被引用!

11
单击通知后打开应用程序
我的应用程序中有一条包含以下代码的通知: //Notification Start notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); int icon = R.drawable.n1; CharSequence tickerText = "Call Blocker"; long when = System.currentTimeMillis(); //now Notification notification = new Notification(icon, tickerText, when); Intent notificationIntent = new Intent(context, Main.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); Context context = getApplicationContext(); CharSequence title = "Call Blocker"; …

10
带有可点击链接的Android TextView:如何捕获点击?
我有一个TextView呈现基本HTML,包含2个以上的链接。我需要捕获链接的点击并打开链接-在我自己的内部WebView中(而不是在默认浏览器中)。 处理链接呈现的最常见方法似乎是这样的: String str_links = "<a href='http://google.com'>Google</a><br /><a href='http://facebook.com'>Facebook</a>"; text_view.setLinksClickable(true); text_view.setMovementMethod(LinkMovementMethod.getInstance()); text_view.setText( Html.fromHtml( str_links ) ); 但是,这会导致链接在默认的内部Web浏览器中打开(显示“使用...完成操作”对话框)。 我尝试实现一个onClickListener,当单击该链接时会正确触发该onClickListener,但是我不知道如何确定单击了哪个WHICH链接... text_view.setOnClickListener(new OnClickListener(){ public void onClick(View v) { // what now...? } }); 另外,我尝试创建一个自定义LinkMovementMethod类并实现onTouchEvent ... public boolean onTouchEvent(TextView widget, Spannable text, MotionEvent event) { String url = text.toString(); // this doesn't work because …

11
安装应用被Play保护阻止
尝试安装签名的应用程序(app-release.apk)时,显示“被Play保护阻止”警报,并且未安装该应用程序。但是,可以安装未签名的应用程序(app-debug.apk),不会出现问题。 错误信息: Play Protect无法识别此应用的开发者。来自未知开发人员的应用程序有时可能不安全。 为什么会发生此错误?有什么解决方案?

11
无法添加窗口-令牌android.os.BinderProxy无效;您的活动正在进行吗?
我尝试通过Facebook API连接到Facebook,我遵循以下示例:https : //github.com/facebook/facebook-android-sdk/tree/master/examples/simple 一切正常,但是当我尝试编辑一些代码时,我的意思是我想在登录成功后显示对话框发布消息,如下所示: public void onAuthSucceed() { mText.setText("You have logged in! "); //This is the code to call the post message dialog. mFacebook.dialog(Example.this, "feed",new SampleDialogListener()); } 我在logcat中收到此错误: 03-02 13:32:08.629: E/AndroidRuntime(14991): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@405180f8 is not valid; is your activity running? 03-02 13:32:08.629: E/AndroidRuntime(14991): …
116 android  facebook 

10
android布局:此标记及其子代可以替换为一个<TextView />和一个复合drawable
当在特定的XML文件上运行布局时,得到以下信息: This tag and its children can be replaced by one &lt;TextView/&gt; and a compound drawable 以下xml代码应进行哪些更改: &lt;LinearLayout android:id="@+id/name_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/grouplist_single_left_grey_area" &gt; &lt;ImageView android:id="@+id/photo_image" android:layout_width="@dimen/thumbnail_width" android:layout_height="@dimen/thumbnail_height" android:paddingBottom="5dip" android:paddingTop="5dip" android:paddingRight="5dip" android:paddingLeft="5dip" android:layout_marginRight="5dip" android:clickable="true" android:focusable="true" android:scaleType="fitCenter" android:src="@*android:drawable/nopicture_thumbnail" android:background="@drawable/photo_highlight" /&gt; &lt;TextView android:id="@+id/name" android:paddingLeft="5dip" android:layout_weight="1" android:layout_width="0dip" android:layout_height="wrap_content" android:gravity="center_vertical" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/LinearLayout&gt; 这是在屏幕上的样子: …
116 android  layout 


5
错误:无此类属性:类的组:org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
我想在我的项目中使用RecyclerViewLib,为此我下载了它并将其作为模块导入到我的空“ hello world” Android项目中。我正在使用sdk Manager v24使用android studio v1.0.1,这是我的app / build.gradle apply plugin: 'com.android.application' android { compileSdkVersion 17 buildToolsVersion "19.1.0" defaultConfig { applicationId "com.example.mk.dragdrop4" minSdkVersion 14 targetSdkVersion 17 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: …

17
Genymotion,“无法加载VirtualBox引擎。” 在小牛上。VBox设置正确
我不断收到以下错误: 我已经重新安装,删除并尝试了一切,让Genymotion再次工作。 我没有所需的设备,但是Genymotion的工作很完美,直到Mavericks更新,我一直在努力让它重新工作。 MacBook Pro,Retina 13英寸,2013年初。i5,8GB。 我正在为OS X运行1.3.1版本。我确实也安装了Virtualbox 4.3和Oracle_VM_VirtualBox_Extension_Pack-4.3.0-89960.vbox-extpack。 我的Virtualbox正常启动,没有任何错误。我尝试了将vbox放在我的$ PATH上的环境变量,各种各样的事情。没用! 我不知道该怎么办,外面有人遇到类似问题并解决了吗? 编辑:日志: Oct 28 09:49:36 [Genymotion] [Warning] **** STARTING GENYMOTION **** Oct 28 09:49:36 [Genymotion] [Warning] Genymotion Version: Genymotion 1.3.1 Oct 28 09:49:36 [Genymotion] [Debug] Network request to URL: "/launchpad/last_version/mac/x64/" Oct 28 09:49:39 [Genymotion] [Debug] Genymotion server informs that …

8
如何使用Android通过Request发送JSON对象?
我想发送以下JSON文本 {"Email":"aaa@tbbb.com","Password":"123456"} 到Web服务并读取响应。我知道如何读取JSON。问题是上述JSON对象必须以变量名发送jason。 我该如何从android做到这一点?创建请求对象,设置内容标头等步骤是什么。

13
Android Studio 0.4在APK META-INF / LICENSE.txt中复制的重复文件
将Studio从0.3.7更新到0.4.0后,我无法编译项目。我找到了一个关于stackoverflow的解决方案:复制了重复的文件(Android Studio 0.4.0) 我将项目更新为gradle 0.7。+,但是我不知道接下来的字符串应该放在哪里: android { packagingOptions { exclude 'META-INF/LICENSE.txt' } } 我的logcat:日志 Execution failed for task ':Prog:packageDebug'. &gt; Duplicate files copied in APK META-INF/LICENSE.txt File 1: /home/scijoker/AndroidStudioProjects/ProgProject/Prog/libs/httpclient-4.1.1.jar File 2: /home/scijoker/AndroidStudioProjects/ProgProject/Prog/libs/httpclient-4.1.1.jar PS开发在Ubuntu 13.04中


7
读取一个简单的文本文件
我正在尝试在示例Android应用程序中读取一个简单的文本文件。我正在使用下面的书面代码来阅读简单的文本文件。 InputStream inputStream = openFileInput("test.txt"); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); 我的问题是:我应该将该"test.txt"文件放在项目的什么位置?我试过将文件放在"res/raw"和"asset"文件夹下,但是我得到了exception "FileNotFound"上面编写的代码的第一个实时执行的时间。 谢谢您的帮助

7
使用“ this”和类名
我正在做Android编程,并且正在学习有关Intent的知识,当时我看到一个构造函数,对我的C#而言,这看起来很时髦。电话是: Intent myIntent = new Intent(CurrentActivity.this, NextActivity.class); 这两个参数对我来说都是新的。类名中如何有一个静态的“ .this”?这是Java还是Android?我假设这与只是说“ this”相同,因为我处于的上下文中CurrentActivity,但是我不知道如何从Class名称本身中调用“ this”。也。“ .class”看起来像是用于反射的,我在C#中很熟悉,但是对此的任何见识也将受到欢迎。 谢谢。
115 java  android  this 

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.