草庐IT

programmatic-config

全部标签

android - 如何设置应用:tabBackground of a tabLayout programmatically?

这是我的代码:这是一个tabLayout,我setupWith一个Viewpager但是我该如何以编程方式设置它呢?app:tabBackground="@drawable/tab_color_selector"以编程方式设置此tabBackground非常重要,因为我希望颜色根据用户选择的主题而改变这些是我已经尝试过的方法,但没有一个起作用:tabLayout.setBackground(getResources().getDrawable(R.drawable.tab_color_selector));tabLayout.setBackgroundResource((R.drawa

安卓 : Turn on a device programmatically

我有一部连接到太阳能充电器的智能手机。白天,它可以正常供电。但在夜间,有时它会因缺乏能量而自行关闭。我的问题是:当电池电量超过一定百分比时,可以(以编程方式)将其重新打开吗?我正在寻找一种干净合法的方式。我对缺陷或漏洞不感兴趣。我在官方文档中什么也没找到。谢谢。 最佳答案 执行此操作的机制依赖于替换电池动画脚本,该脚本在设备关闭但接通电源时运行,通常会显示正在充电的电池图标。脚本的名称因设备而异,但一般位于/system/bin目录下。三星设备通常调用脚本playlpm,我看到的其他脚本名称包括ipod、lpm和battery_ch

java - 约束布局 : How to add several views programmatically?

我想向ConstraintLayout添加2个按钮。我当前的代码如下:protectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);ConstraintLayoutlayout=(ConstraintLayout)findViewById(R.id.activity_main);ConstraintSetset=newConstraintSet();set.clone(layout);//Button1:B

android - 谷歌分析 w/Android : Programmatically set ga_reportUncaughtExceptions?

tl;dr有没有办法在不使用Android中的xml配置的情况下以编程方式为GoogleAnalytics(v4)启用reportUncaughtExceptions?更长的解释我在Android应用程序中使用GoogleAnalyticsv4,我需要一种方法来根据构建风格设置两个不同的跟踪ID。我使用的是通用的global_tracker.xml配置(见下文),尽管我需要一种方法来根据风格“动态注入(inject)”跟踪ID。300truetrueUA-xxxxxx-xx为了避免在构建风格源文件夹中有重复的xml配置,我直接使用trackingId初始化跟踪器并以编程方式设置属性。m

android - 获取安卓 :windowSoftInputMode attribute programmatically on Android

我知道可以使用以下方法以编程方式设置android:windowSoftInputModelist属性:getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);有没有办法以编程方式获取这个值?我没有看到相应的getter方法。 最佳答案 找到解决方案,没有“方便”的获取方法,但您可以轻松地手动查询窗口属性:intmode=getActivity().getWindow().getAttributes().soft

android - Phonegap android 使用 config.xml 添加 windowSoftInputMode

我正在创建一个phonegap应用程序,对于android构建,我想使用config.xml设置Andriodlist文件的windowSoftInputMode属性。有什么方法可以使用config.xml或命令行来完成。请提出建议。提前致谢。 最佳答案 在您的config.xml文件中添加以下首选项:此外,您还必须禁用全屏首选项:查看更多:Android+PhoneGap:android:windowSoftInputModedoesn'tseemtoworkCordovaBug 关于

安卓进度条 : how to set secondary color programmatically

我需要以编程方式设置辅助进度条颜色。我只看到方法ProgressBar.setProgressDrawable(drawable)用于设置主色,但没有设置副色的方法。我该怎么做? 最佳答案 ProgressBar.getProgressDrawable()返回一个LayerDrawable,其中:LayerDrawableprogressDrawable=(LayerDrawable)getProgressDrawable();DrawablebackgroundColor=progressDrawable.getDrawable(

android - 找不到 ionic.config.json 文件

当我运行ionicbuildandroid我收到这个错误-Couldn'tfindionic.config.jsonfile.AreyouinanIonicproject?我在项目文件夹中..有人要吗? 最佳答案 前往ionic.io创建一个新应用。然后在您的应用程序的根文件夹中创建ionic.config.json文件,内容如下{"name":"your_app_name","app_id":"your_app_id"}然后运行命令“ionicbuildandroid”,它应该可以工作。

java - 设置安卓 :windowIsFloating programmatically

如何以编程方式设置以下Activity样式属性true 最佳答案 一个可能的解决方案是创建一个仅设置了windowIsFloating属性的新样式。然后,覆盖目标Activity的getTheme方法以设置该样式。(假设AppTheme.NoActionBar是您当前的风格)。styles.xmltrueTargetActivity.java@OverridepublicResources.ThemegetTheme(){Resources.Themetheme=super.getTheme()theme.applyStyle(R.

android - Holoeverywhere : how to programmatically remove at runtime the action bar from an activity

在Activity中删除操作栏的正确方法是什么?我的Activity扩展了org.holoeverywhere.app.Activity我有一个扩展org.holoeverywhere.app.Application的自定义应用程序类,并在启动时执行此静态代码:ThemeManager.setDefaultTheme(ThemeManager.DARK);ThemeManager.map(ThemeManager.DARK,R.style.Holo_Demo_Theme);ThemeManager.map(ThemeManager.LIGHT,R.style.Holo_Demo_The