从自定义数字键盘获取数据

时间:2017-01-20 13:52:30

标签: android custom-keyboard

我有一个自定义数字键盘。我想用它来写一个PIN但我不知道如何在按下每个按钮后获取数据,以及如何将其保存在带有字符串的密码中。 Anyones知道怎么做吗? Resultat没有在EditText上显示,但我需要使用它发送到服务器并检查是否正确。

这是我的键盘课。现在它只显示keyboard.xml。

如何从每个按钮获取信息并将其保存在String ??

public class PinFragment extends FragmentActivity implements View.OnClickListener {

    private StatusFragment.StatusListener statusListener;
    public static VerificationFragment newInstance() {
        return new VerificationFragment();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_pin);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.

        TextView text_log_small_pass = (TextView) findViewById(R.id.text_log_small_pass);
        TextView t9_key_forgot = (TextView) findViewById(R.id.t9_key_forgot);
        TextView text_button_back_to_log = (TextView) findViewById(R.id.button_back_to_log);


        //font to use
        Typeface fonts = Typeface.createFromAsset(getAssets(), "fonts/Itelma_Kor_Net_Normal_6.ttf");


        text_log_small_pass.setTypeface(fonts);
        t9_key_forgot.setTypeface(fonts);
        text_button_back_to_log.setTypeface(fonts);


        Button button_back_to_log = (Button) findViewById(R.id.button_back_to_log);
        button_back_to_log.setOnClickListener(this);
        button_back_to_log.getElevation();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {

            case R.id.button_back_to_log:
                {
                    Intent intent = new Intent(this, LoginFragment.class);
                    startActivity(intent);
                }
            case R.id.t9_key_1:
                {

                }
            case R.id.t9_key_2:
                {

                }
            case R.id.t9_key_3:
                {

                }
            case R.id.t9_key_4:
                {

                }
            case R.id.t9_key_5:
                {

                }
            case R.id.t9_key_6:
                {

                }
            case R.id.t9_key_7:
                {

                }
            case R.id.t9_key_8:
                {

                }
            case R.id.t9_key_9:
                {

                }
            case R.id.t9_key_0:
                {

                }
            default:
                {
                    break;
                }
        }
    }
}

0 个答案:

没有答案