在我的应用程序中,我有一个EditText默认输入类型android:inputType="textPassword"由deault 设置为.它有一个CheckBox右边的,当被选中时,将EditText的输入类型更改为NORMAL PLAIN TEXT.代码是
password.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
Run Code Online (Sandbox Code Playgroud)
我的问题是,当取消选中CheckBox时,它应该再次将输入类型设置为PASSWORD.我用它完成了 -
password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
Run Code Online (Sandbox Code Playgroud)
但是,该edittext中的文本仍然可见.令人惊讶的是,当我更改orienatation时,它会自动将输入类型设置为PASSWORD,并且内部的文本是项目符号(显示为密码).
有没有办法实现这个目标?
我需要椭圆化多行文本视图.我的组件足够大,可以显示椭圆至少4行,但只显示2行.我试图改变组件的最小和最大行数,但它什么都没改变.
经过对论坛的大量研究,现在我知道在双SIM卡手机中无法找到两张SIM卡的IMSI或SIM序列号(除了联系制造商).现在我改变的问题是,我们可以检测到手机有两个SIM吗?我相信它可以用一些智慧来检测.我能想到的几个方法是:
拨打USSD代码并跟踪IMEI号码的日志(我在印度尝试使用*139#.它有效.)这将给我SIM卡的IMEI号,我从中拨打了USSD代码.(假设手机遵循Android指南并且有两个IMEI号码.)
存储SIM的SIM序列号和/或IMSI.并且在检测到任何其他IMSI /序列号之后,即使手机没有重新启动(即SIM切换),也可以通过跟踪某些日志或某些广播事件处理来实现.
通过拨打*06#,您将看到两个IMEI号码.通过某种方式,获得这两个数字.(像屏幕捕获和文本图像解析之类的东西.)
如果有人能想到其他方式,他们是最受欢迎的.我真的很感激这方面的任何帮助.此外,如果任何人有关于任何制造商API或链接的任何信息,请与社区人员分享.
编辑
如果您想在计算机启动时或基于事件执行任何任务,这将非常有用
回到问题
我有两个问题:
我想在启动命令提示符时执行一些特定的命令.
例如cls,清除我的命令提示符.
我想在批处理文件中执行一些命令,并等待用户输入新命令(如果有的话).
例如,一个批处理文件,它将用户带到某个指定的文件夹,然后等待用户从命令提示符重命名/删除文件.
我该怎么做?
我使用以下drawable定义了一个循环进度条" "ciruclar_progress_bar.xml""
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<item android:id="@android:id/progress">
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thicknessRatio="25.0" >
<gradient
android:centerColor="@color/gray"
android:endColor="@color/gray"
android:startColor="@color/gray"
android:type="sweep" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<shape
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thicknessRatio="25.0" >
<gradient
android:centerColor="@color/green"
android:endColor="@color/green"
android:startColor="@color/green"
android:type="sweep" />
</shape>
</item>
Run Code Online (Sandbox Code Playgroud)
ProgressBar我使用以下代码在我的布局中使用了这个drawable
<ProgressBar
android:id="@+id/progressWheel"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="152dp"
android:layout_height="152dp"
android:layout_centerInParent="true"
android:progress="100"
android:indeterminate="false"
android:progressDrawable="@drawable/circular_progress_bar" />
Run Code Online (Sandbox Code Playgroud)
我使用以下代码显示progressBar的进度
ProgressBar
(使用二次进度,因为绿色应该位于环的黑色顶部.)
这将绘制圆形ProgressBar,其起始位置在右侧(0°),如下图所示

我希望从顶部开始进度,如下图所示

我试过放入ProgressBardrawable xml的渐变标签,但没有运气.有什么办法可以从顶部开始扫掠角度吗?
在我的应用程序中,我有一个布局RelativeLayout,我想在运行时以编程方式设置边距.但是,当我这样做时,它让我ClassCastException说FrameLayout不能投RelativeLayout.我没有使用任何FrameLayout,也没有导入FrameLayout.问题仍然存在.我使用的xml是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_root"
android:background="@color/menu_bg"
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/ll_lhs_menu"
android:layout_width="300dip"
android:layout_height="fill_parent"
android:background="@color/menu_bg"
android:orientation="vertical">
.....
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_right"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:background="@drawable/capture_port"
android:scrollbars="none" >
....
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的onCreate,我将边距设置为父布局:
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
_rootLayout = (RelativeLayout) findViewById(R.id.rl_root);
RelativeLayout.LayoutParams _rootLayoutParams = new RelativeLayout.LayoutParams(_rootLayout.getWidth(), _rootLayout.getHeight());
_rootLayoutParams.setMargins(300, 0, 300, 0);
_rootLayout.setLayoutParams(_rootLayoutParams);
}
Run Code Online (Sandbox Code Playgroud)
这是LogCat:
07-18 21:12:39.410: E/AndroidRuntime(7663): FATAL EXCEPTION: …Run Code Online (Sandbox Code Playgroud) android classcastexception android-layout android-relativelayout android-framelayout
在我的应用程序中,我想将8 dip的上下边距设置为textview.所以,如果我这样做 -
<TextView
android:id="@+id/tv_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/settings_plain_text"/>
Run Code Online (Sandbox Code Playgroud)
它的风格内容很好 -
<style name="settings_plain_text">
<item name="android:layout_marginTop"> 8dip </item>
<item name="android:layout_marginBottom"> 8dip </item>
<item name="android:textSize"> 18sp </item>
</style>
Run Code Online (Sandbox Code Playgroud)
但是当我以编程方式将相同的样式应用于textview时 -
textview.setTextAppearance(context, R.style.settings_plain_text);
Run Code Online (Sandbox Code Playgroud)
它没有显示我设置的顶部和底部边距.请帮忙.
我想有条不紊地将TextView的文本设置为其中一个或另一个.
Android数据绑定文档建议您可以在文本是视图模型的属性时有条件地设置文本.例如
android:text="@{user.displayName != null ? user.displayName : user.lastName}"
Run Code Online (Sandbox Code Playgroud)
但有没有办法从strings.xml中设置文本而不是在我的视图模型中添加它?我想要这样的东西 -
android:text="@{viewModel.expanded ? @string/collapse : @string/expand}"
Run Code Online (Sandbox Code Playgroud)
XML看起来有点像这样:
<?xml version="1.0" encoding="UTF-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:bind="http://schemas.android.com/apk/res-auto">
<data class="TravellerInfoBinding">
<import type="android.view.View" />
<variable name="viewModel" type="com.myproject.viewmodel.TravellerInfoViewModel" />
</data>
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/expandable_arrow_blue" />
<TextView style="@style/primary_pair_element_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{viewModel.expanded ? @string/taxes_fees_detail : @string/hide_taxes_fees_detail}"
android:textSize="12sp" />
</LinearLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)
这是我的视图模型 -
package com.myproject.viewmodel;
imports...
public class TravellerInfoViewModel extends BaseObservable {
@Bindable
private final TaxDetailsViewModel taxDetailsViewModel;
@Bindable
private boolean expanded;
Constructor....
public boolean isExpanded() …Run Code Online (Sandbox Code Playgroud) 我使用SecretKey加密应用程序中的敏感数据.目前我将我的SecretKey以Base64编码格式存储在DB或SharedPrefs中,这不是在根电话上存储Secret的安全位置.因此,我想将我的SecretKey移动到Android KeyStore.我面临的问题是当我尝试使用Google的示例代码时,它需要一个PrivateKey而不是SecretKey.我无法找到一种方法将我的SecretKey存储在KeyStore中并获取它以供以后使用.我试过这个:
private static void writeSecretKeyToKeystore(SecretKey secretKey, Context context) {
KeyStore keyStore = null;
try {
keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null);
KeyStore.SecretKeyEntry secretKeyEntry = new KeyStore.SecretKeyEntry(secretKey);
keyStore.setKeyEntry("Key", secretKeyEntry.getSecretKey().getEncoded(), null);
} catch (KeyStoreException e) {
e.printStackTrace();
} catch (CertificateException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
当我尝试上面的代码时,它会抛出异常Operation not supported because encoding is unknown.
任何示例代码都会有很大帮助.
android ×9
cmd ×1
command ×1
data-binding ×1
dual-sim ×1
ellipse ×1
encryption ×1
imei ×1
keystore ×1
multiline ×1
passwords ×1
secret-key ×1
textview ×1
windows ×1