对于某些EditText视图,我想使用自定义键盘而不是软键盘.
问题是当我EditText第一次点击一个键盘时显示.当我第二次点击时 - 软键盘终于消失了.
这种行为可能是什么原因?
这是我使用的代码:
package pkleczek.profiwan.keyboards;
import android.app.Activity;
import android.inputmethodservice.KeyboardView;
import android.text.InputType;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
public abstract class CustomKeyboard {
/** A link to the KeyboardView that is used to render this CustomKeyboard. */
protected KeyboardView mKeyboardView;
/** A link to the activity that hosts the {@link #mKeyboardView}. */
protected Activity mHostActivity;
/** Returns whether the CustomKeyboard is visible. */
public boolean isCustomKeyboardVisible() {
return …Run Code Online (Sandbox Code Playgroud) IMPORTANT: This question is no longer relevant.
In a Django 1.7 migration I try to create Comment entries programatically with the following code:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
def create_genericcomment_from_bookingcomment(apps, schema_editor):
BookingComment = apps.get_model('booking', 'BookingComment')
Comment = apps.get_model('django_comments', 'Comment')
for comment in BookingComment.objects.all():
new = Comment(content_object=comment.booking)
new.save()
dependencies = [
('comments', '0001_initial'),
('django_comments', '__first__'),
]
operations = [
migrations.RunPython(create_genericcomment_from_bookingcomment),
]
Run Code Online (Sandbox Code Playgroud)
And it produces an error:
TypeError: 'content_object' is an …
我做了一个小测试,在第二个测试中我得到一个断言错误(0 而不是 1):
package tests;
import static org.junit.Assert.*;
import org.junit.Test;
import javax.swing.*;
public class MenuTest {
@Test
public void testElementsAddition() {
JMenuItem mItem1 = new JMenuItem();
JMenuItem mItem2 = new JMenuItem();
JMenu menu = new JMenu();
mItem1.add(mItem2);
assertEquals(1, mItem1.getComponentCount());
menu.add(mItem1);
assertEquals(1, menu.getComponentCount());
}
}
Run Code Online (Sandbox Code Playgroud)
任何想法为什么会发生这种情况?