我需要在应用程序启动时显示虚拟键盘,但到目前为止我都失败了.
我在方法"OnCreate"中使用此代码来显示虚拟键盘
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(txtBuscar.getId(), InputMethodManager.SHOW_FORCED);
Run Code Online (Sandbox Code Playgroud)
此代码可以随时在任何屏幕上正常工作,但在"第一个"活动开始时不起作用.为什么?
当我开始另一个活动时它尝试了它并且它可以工作,但是当我开始"第一个"活动时它不起作用.
我试图把这个代码放在事件"OnCreate"等等......但它似乎不起作用.
无论如何,当我启动应用程序时,"强制"显示键盘?
提前致谢.
我有一个包含2个cardview的片段,其中包含多个控件.
在第二张cardview 下面我有一个recyclerview,这很完美.
问题是recyclerview从屏幕底部开始,滚动recylcerview非常小.
以前使用过listview,这使我保持适合你的内容,从而立即滚动屏幕,但recylclerview不能.
当我在recyclerview中滚动时,如何进行控制,就像视差效果一样?
编辑:更清楚,想象一个片段中的2张卡片,这些占据屏幕的80%,其中上面是一个带有100个项目列表的回收者视图,但是卷轴是如此微小......列表视图让我适应"内容"并立即滚动整个屏幕.
这是我的XML布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/svScroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<include
android:id="@+id/cvCampos1"
layout="@layout/ctlcabeceralibreta" />
<include
android:id="@+id/cvCampos2"
layout="@layout/ctlcabeceralibreta2" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rvRegistros"
android:layout_width="fill_parent"
android:layout_height="1000dp"
android:layout_below="@id/cvCampos2"
android:scrollbars="vertical" />
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是截图:

android android-appcompat android-layout android-cardview android-recyclerview
我刚刚升级了我的应用程序以使用AppCompat v22.1.0,我从AppCompat布局XML文件中获得以下异常:
removing attribute http://schemas.android.com/apk/res/android:layout_marginEnd
from <ImageView>
removing attribute http://schemas.android.com/apk/res/android:textAlignment
from <android.support.v7.internal.widget.DialogTitle>
removing attribute http://schemas.android.com/apk/res/android:layoutDirection
from <LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我升级到JDK的v1.8版本,但也无法正常工作.
有谁知道如何更改按钮颜色?
但是一个特定的按钮,而不是使用XML的应用程序的所有按钮.
即使使用AppCompat库,android:backgroundTint属性也不适用于pre-Lollipop.只有来自主题的colorButtonNormal才能在pre-Lollipop上运行.
真的吗?多可惜
我正在使用这个drawable(是一个简单的绿色)和一个按钮,但是当我使用按钮时,结果是高于普通按钮.
这是文件btn_green.xml
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<item android:state_pressed="true"><shape>
<solid android:color="#ff5722" />
<corners android:radius="4dp" />
</shape></item>
<item android:state_focused="true"><shape android:shape="rectangle">
<solid android:color="#4caf50" />
<corners android:radius="4dip" />
<stroke android:width="1dip" android:color="#F0FC00" />
</shape></item>
<item><shape>
<solid android:color="#4caf50" />
<corners android:radius="4dp" />
</shape></item>
Run Code Online (Sandbox Code Playgroud)
按钮是这样的:
<android.support.v7.widget.AppCompatButton
android:id="@+id/btnIngresar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_green"
android:text="Hello"
android:textStyle="bold" />
Run Code Online (Sandbox Code Playgroud)
当我使用drawable时,按钮高于普通按钮(没有drawable),我不知道为什么.
java eclipse android android-appcompat android-support-library
有人可以告诉我如何从一个函数更新控件Textview Android?我已深入搜索互联网并看到许多人提出同样的问题,我测试了线程但无法工作,有人有一个简单的工作示例吗?例如,调用一个函数(在循环中运行几次)并且函数在TextView中写入,但问题是在函数未完成运行之前,它会向我显示文本.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
while(condition) //here freezes the UI and the text in textview only shows when the loop ends
{
HardWork();
}
}
public void HardWork() {
txtProgreso.append("Test Line" + "\n\n");
};
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我在Visual Basic中有一个加密的字符串。NET 2008,加密和解密的功能如下:
Imports System.Security.Cryptography
Public Shared Function Encriptar(ByVal strValor As String) As String
Dim strEncrKey As String = "key12345"
Dim byKey() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
Try
byKey = System.Text.Encoding.UTF8.GetBytes(strEncrKey)
Dim des As New DESCryptoServiceProvider
Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strValor)
Dim ms As New MemoryStream
Dim cs As New CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Return Convert.ToBase64String(ms.ToArray())
Catch ex As Exception
Return ""
End …Run Code Online (Sandbox Code Playgroud) 我有一个显示通知的功能,我从各种活动中调用.
public static void CrearNotificacion(Context pContexto, String pTituloBarra, String pTitulo, String pTexto){
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) pContexto.getSystemService(ns);
Notification notification = new Notification(R.drawable.icono, pTituloBarra, System.currentTimeMillis());
notification.defaults |= Notification.DEFAULT_SOUND;
Intent notificationIntent = new Intent(pContexto, pContexto.getClass());
PendingIntent contentIntent = PendingIntent.getActivity(pContexto, 0, notificationIntent, 0);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(pContexto, pTitulo, pTexto, contentIntent);
mNotificationManager.notify(1, notification);
}
Run Code Online (Sandbox Code Playgroud)
工作完美,问题是按下通知打开创建通知的活动,这是错误的,我认为当我选择通知时,notiifcacion活动不应该打开.
为什么?有没有办法解决这个问题?
我选择通知时不想打开任何活动.
谢谢你们.