MainActivity for the In-App Keyboard tutorial on the SSaurel's Channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ssaurel.inappkeyboard; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.text.InputType; | |
import android.view.inputmethod.EditorInfo; | |
import android.view.inputmethod.InputConnection; | |
import android.widget.EditText; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
EditText editText = (EditText) findViewById(R.id.editText); | |
MyKeyboard keyboard = (MyKeyboard) findViewById(R.id.keyboard); | |
editText.setRawInputType(InputType.TYPE_CLASS_TEXT); | |
editText.setTextIsSelectable(true); | |
InputConnection ic = editText.onCreateInputConnection(new EditorInfo()); | |
keyboard.setInputConnection(ic); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment