2

私は自分のプログラムの入力画面を準備し、そこに edittext と ImageViews を配置しました。問題は、仮想キーボードを使用して edittext 内にテキストを入力できることですが、問題は、テキストを使用した後、編集テキストから抜け出せず、カーソルは編集テキストボックスにのみ残ります。フォームを続行するためにクリックする必要がある imageView が下にありますが、その時点ではクリックできません。助けてください!!!

私のコードは

私のxml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
         android:id="@+id/begin_"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginLeft="170dp"
         android:layout_marginTop="220dp"
         android:src="@drawable/begin" />

    <ImageView
        android:id="@+id/enter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="150dp"
        android:layout_marginTop="30dp"
        android:src="@drawable/enter_name" />

     <ImageView
        android:id="@+id/roof"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/roof" />

     <EditText
         android:id="@+id/editText2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginLeft="180dp"
         android:layout_marginTop="180dp"
         android:ems="8"
         android:inputType="textMultiLine" 
         android:imeOptions="actionDone"/>
</FrameLayout>

私のメインJavaクラス

package game.pack;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.*;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;

public class Begin extends Activity implements View.OnClickListener  {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

            setContentView(R.layout.entry);

        ImageView begin = (ImageView) findViewById(R.id.begin_);
        begin.setOnClickListener(this);
    }

    public void onClick(View v) {
        switch(v.getId()) {
        case R.id.begin_:
            setContentView(new SushiMain(this));
            break;
        default:
            break;
        }
    }
}

私のアンドロイドマニフェストは

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="game.pack"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <activity
            android:name=".FrontScreen"
            android:screenOrientation="landscape"
            android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".Begin"
            android:screenOrientation="landscape"
            android:label="@string/app_name" 
            >
          <intent-filter>
                  <action android:name="begingame" />
                  <category android:name="android.intent.category.DEFAULT" />
          </intent-filter>
        </activity>

        <activity
            android:name=".Sushitap"
            android:screenOrientation="landscape"
            android:label="@string/app_name" >

        <intent-filter>
                <action android:name="gameover" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>

4

6 に答える 6

1

EditTextに View.OnKeyListener を使用して、 EditText に入力した後に ENTER キーを押したときに EditText からフォーカスを削除します。

ditText.setOnKeyListener(onSoftKeyboardDonePress);

    private View.OnKeyListener onSoftKeyboardDonePress=new View.OnKeyListener() 
    {
        public boolean onKey(View v, int keyCode, KeyEvent event) 
        {
            if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
            {
                 // code to hide the soft keyboard
                 EditTexst.clearFocus();
                 EditTexst.requestFocus(EditText.FOCUS_DOWN);            
            }
            return false;
        }
    };
于 2012-06-29T10:20:25.957 に答える
0

やあみんな私の問題は解決しました!!! 実際、私は他のビューからこのビューに移動していました。最初のビューでは、レイアウトIDによって現在のクラスアクティビティを呼び出していたため、この場合、imageviewは通常のボタンとしてではなく、単なるビューとして動作していました。

したがって、最初のビューでは、インテントを使用して、上記で投稿したアクティビティのクラスを呼び出しました。これにより、タスクが正常に完了しました。

皆さんの時間と努力に感謝します...大いに感謝します!!!!

ありがとうございました!!!

于 2012-06-29T12:30:49.117 に答える
0

xml の edittext をコードにリンクする必要があります。oncreate メソッドに追加します

EditText edittext= (EditText ) findViewById(R.id.editText2);
于 2012-06-29T10:22:22.657 に答える
0

これを edittext のレイアウトファイルに入れてみてはいかがでしょうか?

 android:focusableInTouchMode="true"
于 2012-06-29T10:23:43.227 に答える
0

アプリで編集テキストとその横に画像ビューが必要な場合は、次のコードを使用できます。layout.xml では、画像付きの edittext にこのコードを追加できます

<LinearLayout        
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white2" >


    <EditText
        android:id="@+id/et_search"
        android:layout_width="280dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="5dp"
        android:drawableRight="@drawable/search_20"
        android:ems="10"
        android:hint="@string/search_brdNm" />

</LinearLayout>

Java クラスでは、次のコードを使用できます。

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.search_asset);

        mEt_search = (EditText) findViewById(R.id.et_search);

    mEt_search.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                String str_searchTxt = mEt_search.getText().toString().trim();
                String str_channelNm = AppConfigurationUtils.getChannelName();
                if (str_searchTxt.length() == 0) {
                    Toast.makeText(getApplicationContext(),
                            getResources().getString(R.string.ENTER_MANDATORY),
                            Toast.LENGTH_LONG).show();
                    return;
                }

            }
        });
}
于 2012-06-29T10:40:34.147 に答える
0

これを試して。

editTextId.clearFocus();
editTextId.requestFocus(EditText.FOCUS_DOWN); // assuming that you want to move the focus to the next View Element. If you want it to go to the previous View, use FOCUS_UP
于 2012-06-29T10:15:24.263 に答える