EditText焦点自动打开键盘(EditText focus opens Keyboard automatically)
当我开始登录活动。 它有两个字段的电子邮件和密码。 电子邮件应获得焦点,但在活动开始时不会自动打开键盘。
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/splash_background_gradient" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginBottom="10dip" android:layout_marginTop="10dip" android:orientation="vertical" > <ImageView android:id="@+id/SplashLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="40dip" android:src="@drawable/splash_logo" /> <EditText android:id="@+id/EmailAddress" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:hint="Email Address" android:maxLines="1" android:nextFocusRight="@+id/Password"> </EditText> <EditText android:id="@+id/Password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="5dip" android:hint="Password" android:inputType="textPassword" /> <Button android:id="@+id/Login" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="10dip" android:background="@drawable/login_button_selector" android:text="@string/login" /> <TextView android:id="@+id/ForgotPassword" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="28dp" android:layout_marginRight="28dp" android:layout_marginTop="10dip" android:text="@string/forgot_password" android:textColor="#000000" android:textSize="7pt"/> </LinearLayout> </ScrollView>
When i start Login Activity. it has two fields email and password. Email should get the focus but not open the keyboard automatically when the activity starts.
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/splash_background_gradient" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginBottom="10dip" android:layout_marginTop="10dip" android:orientation="vertical" > <ImageView android:id="@+id/SplashLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="40dip" android:src="@drawable/splash_logo" /> <EditText android:id="@+id/EmailAddress" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:hint="Email Address" android:maxLines="1" android:nextFocusRight="@+id/Password"> </EditText> <EditText android:id="@+id/Password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="5dip" android:hint="Password" android:inputType="textPassword" /> <Button android:id="@+id/Login" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="25dp" android:layout_marginRight="25dp" android:layout_marginTop="10dip" android:background="@drawable/login_button_selector" android:text="@string/login" /> <TextView android:id="@+id/ForgotPassword" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="28dp" android:layout_marginRight="28dp" android:layout_marginTop="10dip" android:text="@string/forgot_password" android:textColor="#000000" android:textSize="7pt"/> </LinearLayout> </ScrollView>
原文:https://stackoverflow.com/questions/7934801
最满意答案
最可能的原因是没有任何东西保留这个对象,所以它被垃圾收集。 如果您创建一个对象并实现其finalize方法并在其中放置一个puts,您将能够看到这种情况。
尝试在创建工作表的控制器中跟踪您的状态,并将指针作为contextInfo传递给控制器。 如果此状态调解ui元素之间的并发交互,那么负责所有元素的控制器可能无论如何都需要跟踪它。 当然,可能更容易不传递contextInfo并使用哪个回调给表单跟踪它所调用的条件。
The most likely reason is that nothing is retaining this object so it gets garbage collected. If you create an object and implement its finalize method and put a puts in there, you will be able to see that this is the case.
Try tracking your state in the controller that is creating the sheet, and passing a pointer to the controller as the contextInfo. If this state is mediating concurrent interactions between ui elements, it is likely the controller that is responsible for all the elements needs to track it anyway. Of course, it is probably then easier to not pass a contextInfo and using which callback you give the sheet to keep track of what conditions it was called under.
相关问答
更多-
不,传递char**并不一定是安全的,其中void** (这实际上是void*[]函数参数实际上是预期的)。 编译器使您执行显式转换的事实是一个提示。 在实践中,它可能会很好。 但是,严格来说,对于不同类型的T和U ,您通常无法保证sizeof (T*) == sizeof (U*) 。 (例如,您可以想象一个假设的系统,其中sizeof (int*) < sizeof (char*)因为指针到int是对齐的,因此不需要存储最低有效位。)因此,您的swap函数可能使用错误的偏移索引到v数组。 另请参阅com ...
-
MacRuby指针和Obj-C函数通过引用返回值(MacRuby pointers and Obj-C function returning a value by reference)[2022-03-11]
我在MacRuby-devel邮件列表中获得了Watson的解决方案。 我应该编写我的代码: range=Pointer.new(NSRange.type) #though range=Pointer.new("{_NSRange=QQ}") would also work 然后,就像我以前一样 font=txtStor.attribute(NSFontAttributeName,atIndex:index,effectiveRange:range) 如果需要,我可以按range[0]取消引用范围。 ... -
为什么我的Macruby指针不能作为void指针传递?(Why are my Macruby pointers not surviving being passed as void pointers?)[2021-11-19]
最可能的原因是没有任何东西保留这个对象,所以它被垃圾收集。 如果您创建一个对象并实现其finalize方法并在其中放置一个puts,您将能够看到这种情况。 尝试在创建工作表的控制器中跟踪您的状态,并将指针作为contextInfo传递给控制器。 如果此状态调解ui元素之间的并发交互,那么负责所有元素的控制器可能无论如何都需要跟踪它。 当然,可能更容易不传递contextInfo并使用哪个回调给表单跟踪它所调用的条件。 The most likely reason is that nothing is ret ... -
鉴于指针指向“内部标识符”,我不认为你可以对存储在其中的实际值作出任何假设。 如果指针可以指向堆,那么您可能会看到一组可能的值,并且它将在未来微妙(或明显)中断。 为什么不只是创建PolygonType* - > index的一次性反向映射并使用它? Given that the pointer is pointing to an "internal identifier" I don't think you can make any assumptions about the actual values ...
-
你将*f=emptylines放在函数的开头void test2(int *f); 然后你计算emptylines但这不会影响f指向的值。 您需要将该赋值*f=emptylines移至该函数的末尾,在返回之前和计算出emptylines void test2(int *f){ // stuff to calculate emptylines .... *f=emptylines; // at the end } You are putting *f=emptylines in t ...
-
你的showChar和showInt函数正在打印不同的东西。 在showChar ,这个: cout << &name << endl; 打印name的地址,这是一个局部变量 。 在showInt ,您不打印&num ;的值。 而是打印num的值 ,这是一个地址,但不是局部变量的地址。 在showChar ,如果要打印name值作为地址 ,则需要将其转换为其他指针类型,例如void* : cout << (void*)name << endl; 因为operator<< for char*的重载取消引用 ...
-
问题是指针算术。 当你拿一个指针并减去1时,你实际上是减去(1*sizeof(struct)) 。 第一个带有“-sizeof”的等式,你实际上是从指针中减去(sizeof(struct) * sizeof(struct))字节。 合理? The problem is pointer arithmetic. When you take a pointer and subtract 1, you are really subtracting (1*sizeof(struct)). The first equa ...
-
只要您小心保持您的呼叫类型正确,这是完成您描述的相当C语言的方式。 As long as you are careful to keep your calls type-correct, this is a fairly C-idiomatic way to accomplish what you describe.
-
为什么这些函数使用不同的指针和void指针?(Why are different pointers and void pointers being used by these functions?)[2023-06-18]
列出的前四个函数定义了要写入的对象的类型。 所以内部函数可能如下所示: void eeprom_update_float (float *addr, float value) { *addr = value; } 这通过确保目标指针与源变量相同来提供类型安全性好处(例如,不能将float写入uint16_t )。 最终版本void eeprom_update_block()只是将任意内存块写入给定地址。 它可能使用类似memcpy东西: void eeprom_update_block (cons ... -
避免void指针(Avoiding void pointers)[2022-05-24]
您可以删除以下类型: class Token { using Deleter = void(void*); using Func = void(*)(void*); templatestatic void proto(void *ptr) { T t = static_cast (ptr); // do whatever you want here... // ... or use specia ...