Questions tagged «android»

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



5
如何在非活动类(LocationManager)中使用getSystemService?
我无法将主要的Activity OnCreate方法中的任务卸载到另一个类上来进行繁重的工作。 当我尝试从非Activity类调用getSystemService时,将引发异常。 任何帮助将不胜感激 :) lmt.java: package com.atClass.lmt; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.location.Location; public class lmt extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); fyl lfyl = new fyl(); Location location = lfyl.getLocation(); String latLongString = lfyl.updateWithNewLocation(location); TextView myLocationText = (TextView)findViewById(R.id.myLocationText); myLocationText.setText("Your current position …
180 android 


8
设置视图的绝对位置
是否可以在Android中设置视图的绝对位置?(我知道有个AbsoluteLayout,但已弃用...) 例如,如果我有一个240x320px的屏幕,如何添加一个20x20px的屏幕,ImageView使其中心位于位置(100,100)?



9
错误消息“ java.net.SocketException:套接字失败:EACCES(权限被拒绝)”
我收到错误消息 java.net.SocketException:套接字失败:EACCES(权限被拒绝) 当我尝试应用以下代码时。这是我调用的函数,并给了我这个例外。 public void run() { // TODO Auto-generated method stub URL myurl = null; try { myurl = new URL("http://10.0.2.2/list.JSON"); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { URLConnection myconn = myurl.openConnection(); InputStream in = new BufferedInputStream(myconn.getInputStream()); InputStreamReader reader = new InputStreamReader(in); …
180 android  json 

9
如何在翻新库中设置超时?
我在我的应用程序中使用Retrofit库,我想将超时设置为60秒。改装有某种方法可以做到这一点吗? 我以这种方式设置Retrofit: RestAdapter restAdapter = new RestAdapter.Builder() .setServer(BuildConfig.BASE_URL) .setConverter(new GsonConverter(gson)) .build(); 如何设置超时时间?


12
如何以编程方式在EditText上设置焦点(并显示键盘)
我有一个包含一些这样的视图的布局: <LinearLayout> <TextView...> <TextView...> <ImageView ...> <EditText...> <Button...> </linearLayout> 如何以EditText编程方式设置焦点(显示键盘)? 我已经尝试过了,它只有在Activity正常启动时才起作用,但是当在中启动时TabHost,它不起作用。 txtSearch.setFocusableInTouchMode(true); txtSearch.setFocusable(true); txtSearch.requestFocus();

22
INSTALL_FAILED_DUPLICATE_PERMISSION…C2D_MESSAGE
我在应用中使用Google通知,到目前为止,我在清单中做了以下操作: <!-- GCM --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- GCM requires a Google account. --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Keeps the processor from sleeping when a message is received. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- This app has permission to register and receive data message. --> <!-- Creates a custom permission so …

10
应用(22.0.0)和测试应用(21.0.3)的已解决版本不同
升级到API 22并支持lib版本22后,我收到以下警告: 警告:与依赖项“ com.android.support:support-annotations”冲突。应用(22.0.0)和测试应用(21.0.3)的已解决版本不同。 Gradle本身更宽容,但Android Studio却没有那么多。 我没有用21.0.3声明的依赖项...是使用21.0.3的依赖库之一,Google忘记用其余的批处理更新它吗? 我build.gradle的临时演员被削减了 android { compileSdkVersion 22 buildToolsVersion '22' defaultConfig { applicationId "com.REDACTED.android" minSdkVersion 14 targetSdkVersion 22 renderscriptSupportModeEnabled true versionName '1.0.0' versionCode 100 } buildTypes { release { minifyEnabled true zipAlignEnabled true signingConfig signingConfigs.release } debug { minifyEnabled false zipAlignEnabled true signingConfig signingConfigs.debug } } …

2
带有两列的Gridview和自动调整大小的图像
我试图做一个两列的gridview。我的意思是每行并排两张照片,就像这张图片一样。 但由于尺寸不一样,我的照片之间留有空格。这就是我得到的。 如您所见,第一张图片隐藏了图例,该图例显示了联系人姓名和电话号码。并且其他图片没有正确拉伸。 这是我的GridView xml文件。如您所见,columnWidth设置为200dp。我希望它是自动的,因此图片会针对每种屏幕尺寸自动调整大小。 <?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridViewContacts" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="2" android:columnWidth="200dp" android:stretchMode="columnWidth" android:gravity="center" /> 这是项目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" > <ImageView android:id="@+id/imageViewContactIcon" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY" /> <LinearLayout android:id="@+id/linearlayoutContactName" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="5dp" android:paddingTop="5dp" android:paddingBottom="5dp" android:background="#99000000" android:layout_alignBottom="@+id/imageViewContactIcon"> <TextView android:id="@+id/textViewContactName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textStyle="bold" android:textSize="15sp" …

27
如何创建Android Facebook密钥哈希?
我完全不了解这个过程。我已经能够导航到Java SDK中包含keytool的文件夹。尽管我不断收到错误,但openssl无法识别为内部或外部命令。问题是,即使我可以解决这个问题,我该怎么办?以后怎么办?
179 java  android  facebook 

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.