我刚刚开始使用android,并完成了大约5个布局文件.但是,我才意识到我一直在使用@id和@ + id,但我不确定两者之间的确切区别.
我正在制作的程序有几个视图,用户试图基本上找出很多布尔值.听起来很奇怪,但我的意思是我的设备将通过蓝牙连接到另一台设备,然后读取该设备的状态.我基本上显示了该设备当前状态的清单.因此,根据设备的功能,会检查不同的复选框.有没有办法让所有的复选框都不可选?
更好的是,有没有办法将其硬编码到XML文件中?
我知道可以覆盖Android中的Back Button功能,但我想知道是否有一个方法或任何我可以调用的功能与按下硬件按钮相同的功能.
我试图让TripleDES加密工作在Java中.从维基百科的文章下Keying Options,我想用选项1,其中All three keys are independent.
从Cipher文档中可以看到这里的参考指南,但我仍然不清楚.
我正在努力运行示例,并在不同的项目中使用这两行:
Cipher c = Cipher.getInstance("DESede");
Cipher cipher = Cipher.getInstance("TripleDES/ECB/PKCS5Padding");
Run Code Online (Sandbox Code Playgroud)
编译都很好,那有什么区别?我应该使用其中一个吗?这两个都可以使用三个独立的键吗?
无论我到哪里,我都会为我的蓝牙适配器找到这个方法"getBondedDevices()".但是,我有我的平板电脑和另一个蓝牙设备坐在我旁边,我无法弄清楚如何让设备显示在绑定设备列表上.
我目前有一个来自Android的BluetoothChat示例的工作I/O流,但遇到了问题.我的应用程序通过蓝牙连接到蓝牙模块,蓝牙模块又向模块物理连接的设备发送信号.
我的程序调用read()输入流,如果有数据发送,程序可以顺利执行,没有任何问题.但是,实现流的方式不能防止中断连接.如果从设备中物理移除模块,或者设备没有发回任何信号,我的代码就会坐下来等待InputStream.read()通话.
我的read()电话看起来像这样:
try {
Log.i( "1) I/O", "available bits: " + mmInStream.available() );
bytes = mmInStream.read(buffer, 0, length);
Log.i( "2) I/O", "available bits: " + mmInStream.available() );
mHandler.obtainMessage(MainMenu.MESSAGE_READ, bytes, -1, buffer)
.sendToTarget();
} catch (Exception e) {
Log.i(TAG, "Catch Statement" );
Message msg = mHandler.obtainMessage(MainMenu.MESSAGE_TOAST);
Bundle bundle = new Bundle();
bundle.putString( TOAST, "Device has disconnected from the Bluetooth Module." );
msg.setData(bundle);
mHandler.sendMessage(msg);
Log.e(TAG, "disconnected a", e);
connectionLost();
// Start the service …Run Code Online (Sandbox Code Playgroud) 我有自定义按钮应该具有不同的背景,具体取决于它们是否被选中.我想知道是否有办法在XML文件中说明这一点.我有一个Celsius按钮和一个华氏按钮.我希望它能够工作,如果选择了一个,它会保持"按下"而无法点击,而另一个按钮可以被按下.
<Button
android:id="@+id/celsiusButton"
android:text="C"
android:background="@drawable/button_unpressed_shape"
android:layout_weight="3"
android:layout_height="match_parent"
android:layout_width="0dip"
android:gravity="center" />
<Button
android:id="@+id/fahrenheitButton"
android:text="F"
android:background="@drawable/button_unpressed_shape"
android:layout_weight="3"
android:layout_height="match_parent"
android:layout_width="0dip"
android:gravity="center" />
Run Code Online (Sandbox Code Playgroud)
摄氏度按钮默认为选中状态.我在我的代码中尝试这样做,但它似乎很乱:
tempText = (TextView) findViewById( R.id.temperatureId );
celsiusButton = (Button) findViewById( R.id.celsiusButton );
celsiusButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_pressed_shape ) );
celsiusButton.setClickable( false );
celsiusButton.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
if( hasRead ) {
celsiusButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_pressed_shape ) );
celsiusButton.setClickable( false );
fahrenheitButton.setBackgroundDrawable( getResources().getDrawable( R.drawable.button_unpressed_shape ) );
fahrenheitButton.setClickable( true );
temperature = ( ( ( temperature - 32 ) * 5 …Run Code Online (Sandbox Code Playgroud) 我想让我的程序暂停一定的毫秒数,我到底该怎么做?
我发现了不同的方式Thread.sleep( time ),但我认为这不是我需要的.我只想让我的代码在某一行停顿x毫秒.任何想法将不胜感激.
这是C中的原始代码......
extern void delay(UInt32 wait){
UInt32 ticks;
UInt32 pause;
ticks = TimGetTicks();
//use = ticks + (wait/4);
pause = ticks + (wait);
while(ticks < pause)
ticks = TimGetTicks();
}
Run Code Online (Sandbox Code Playgroud)
等待是一个毫秒
我目前有一个应用程序,每张幻灯片都有默认的黑色背景.我想要做的是改变XML文件以获得背景图像.我假设有一个简单的命令,但无法找到我正在寻找的确切内容.
我想要一个图像到我当前屏幕的背景.我不希望背景发生变化,我想把它放在我的XML文件中.以下是我的一个XML标头的示例...
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="9"
android:gravity="center"
>
...
Run Code Online (Sandbox Code Playgroud)
我假设有一些简单的命令,如
android:background="file"
Run Code Online (Sandbox Code Playgroud) 编辑我刚试了一个EditText没有a TextInputLayout,它按预期工作.所以问题必然是新的变化TextInputLayout.
我一直在使用自定义EditText类作为TextInputLayout一个月的孩子.当用户键入时,x会出现在drawableRight字段中.我已经成功地显示图像了drawableLeft,drawableTop和drawableBottom,但设置drawableRight为我提供了一个空白.注意:单击X应该按预期工作的空白区域,文本将被清除.
第一张照片是它最初的样子:
自从升级到support-v4:24.2.0功能已被打破.它现在将"x"放置在drawableBottom应该出现的可绘制集合的位置.第二张图片显示了新的行为:
<android.support.design.widget.TextInputLayout
android:id="@+id/til_delivery_info_state"
android:hint="@string/state_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/large_margin"
android:layout_marginRight="@dimen/large_margin">
<com.example.ui.edittexts.ClearableEditText
android:id="@+id/et_state"
android:inputType="textCapWords|text|textNoSuggestions"
android:nextFocusDown="@+id/et_di_zip_code"
android:text="@={deliveryViewModel.state}"
android:gravity="center_vertical|left"
android:singleLine="true"
android:textSize="@dimen/text_size"/>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
final Drawable drawable = ContextCompat.getDrawable(context, R.drawable.ic_clear_text_gray_x);
final Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
mClearTextIcon.setBounds(0, 0, mClearTextIcon.getIntrinsicWidth(), mClearTextIcon.getIntrinsicHeight());
mClearTextIcon.setVisible(true, false);
final Drawable[] compoundDrawables = getCompoundDrawables();
setCompoundDrawablesWithIntrinsicBounds(
compoundDrawables[0],
compoundDrawables[1],
visible ? …Run Code Online (Sandbox Code Playgroud) android android-edittext android-support-library android-drawable android-textinputlayout
android ×9
xml ×3
bluetooth ×2
background ×1
button ×1
cryptography ×1
device ×1
encryption ×1
java ×1
nio ×1
timedelay ×1
tripledes ×1