Tag: android

以编程方式设置android:layout_centerHorizo​​ntal

在xml中,您可以执行以下操作: <TextView … android:layout_centerHorizontal="true" … /> 我如何,当我有TextView的实例,这样做以编程方式?

RecyclerView项目中的背景select器

我正在使用如下所示的RecyclerView : <android.support.v7.widget.RecyclerView android:id="@+id/list" android:layout_width="320dp" android:layout_height="match_parent"/> 和我的清单项目: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/selector_medium_high"> <com.basf.suvinil.crie.ui.common.widget.CircleView android:id="@+id/circle" android:layout_width="22dp" android:layout_height="22dp"/> <TextView android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="57.5dp"/> </LinearLayout> 详细看这部分android:background="@drawable/selector_medium_high"这是一个普通的select器: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/background_high" android:state_activated="true"/> <item android:drawable="@color/background_high" android:state_pressed="true"/> <item android:drawable="@color/background_high" android:state_checked="true"/> <item android:drawable="@color/background_high" android:state_focused="true"/> <item android:drawable="@color/background_medium"/> </selector> 但是当我运行这个代码,我没有改变背景颜色当我触摸行….

如何捕获onNewIntent()中的新的意图?

我想传递一个新的,但不同的意图到一个活动。 你如何区分新的意图和以前的意图? 什么样的代码进入onNewIntent()? 一个例子将是非常有帮助的。

Android SDK内容加载程序无法使用NullPointerException

我最近刚刚在Eclipse Helios中与Android SDK和AVD Manager进行交互时发生错误 我已经尝试重新安装Eclipse插件和Android SDK,但无济于事。 如果我去“已安装的软件包”页面,点击刷新(或安装或删除一个软件包),我得到一个popup框说 'Android SDK Content Loader' has encountered a problem. parseSdkContent failed java.lang.NullPointerException. 这里是完整的日志: 堆栈跟踪 java.lang.NullPointerException at com.android.ide.eclipse.adt.internal.sdk.Sdk.loadTarget(Unknown Source) at com.android.ide.eclipse.adt.AdtPlugin$10.run(Unknown Source) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) 会话数据 eclipse.buildId=M20100909-0800 java.version=1.6.0_20 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_IE Framework arguments: -product org.eclipse.epp.package.java.product Command-line arguments: -os linux -ws gtk -arch x86 -product org.eclipse.epp.package.java.product […]

ViewPager中的ViewPager

我想创build一个ViewPager(有三个项目),其中每个视图是另一个ViewPager(有两个项目)。 用户然后刷这样的项目: ViewPager1[0] ViewPager2[0] ViewPager1[0] ViewPager2[1] ViewPager1[1] ViewPager2[0] ViewPager1[1] ViewPager2[1] ViewPager1[2] ViewPager2[0] ViewPager1[2] ViewPager2[1] 这怎么可能?

不build议使用Dagger 2.2组件构build器模块方法

我开始使用dagger 2.2,并且不推荐使用“组件”构build器中的模块方法。 这是我的应用程序组件: @Component(modules = ApplicationModule.class) public interface ApplicationComponent { void inject(Application application); } 和应用程序模块: @Module public class ApplicationModule { Application application; public ApplicationModule(Application application) { this.application = application; } @Provides @Singleton Application providesApplication() { return application; } } 这里是生成的类: @Generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://google.github.io/dagger" ) public final class DaggerApplicationComponent implements ApplicationComponent { […]

裁剪位图图像

我如何裁剪位图图像? 这是我的问题,我尝试了一些使用意图的概念,但仍然失败.. 我有一个位图图像,我想裁剪! 这里是代码: Intent intent = new Intent("com.android.camera.action.CROP"); intent.setClassName("com.android.camera", "com.android.camera.CropImage"); File file = new File(filePath); Uri uri = Uri.fromFile(file); intent.setData(uri); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 96); intent.putExtra("outputY", 96); intent.putExtra("noFaceDetection", true); intent.putExtra("return-data", true); startActivityForResult(intent, REQUEST_CROP_ICON); 有没有人可以帮我关于这个@谢谢

支持库VectorDrawable资源$ NotFoundException

我正在使用devise支持库版本23.4.0。 我已经启用了gradle标志 defaultConfig { vectorDrawables.useSupportLibrary = true } 我正在使用生成工具版本23.0.2,但仍然获得Kitkat或更低的ResourcesNotFoundexception。 这是当我使用android:drawableLeft或imageView.setImageResource(R.drawable.drawable_image) 是的,我把这个放在我使用drawable的每一个活动上 static { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); } 这是支持库的错误吗?

只在Android软键盘上显示数字button?

在Android的软键盘上,您可以使用android:inputType="numberDecimal"来设置软键盘来显示数字,而不是使用az键盘。 但是,如果我只想显示顶部数字行1 2 3 4 5 6 7 8 9 0 ,而不是以@ # $ % …开始的以下行,该怎么办? 谢谢!

带有子项的onLineClick不在LinearLayout上触发

我有一个自定义的LinearLayout与一个较小的TextView子。 我希望能够点击没有被TextView覆盖的区域,所以我设置clickable = true和一个onclicklistener到LinearLayout,但onClick不会被触发。 如果我在TextView上设置onclick监听器,它按预期方式工作… 任何人都可以帮忙? ar_item.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ar_item" android:layout_width="202dp" android:layout_height="62dp" android:background="@drawable/bg_item_ar" android:clickable="true"> <TextView android:id="@+id/ar_item_txt" android:layout_width="164dp" android:layout_height="fill_parent" android:paddingBottom="8dp" android:paddingLeft="8dp" android:paddingTop="8dp" android:paddingRight="6dp" android:gravity="center" android:background="#50000000" /> </LinearLayout> 我的自定义LinearLayout public class ARView extends LinearLayout { public ARView(final Context context, String name, String id) { super(context); getLayoutInflater().inflate(R.layout.ar_item, this ,true); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.ar_item, […]