You can create custom character Picker, same way we can make custom keyboard using this concept.
import android.app.Activity;
import android.os.Bundle;
import android.text.method.CharacterPickerDialog;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.Toast;
public class CharacterPickerDialogActivity extends Activity
{
private CharacterPickerDialog cpd = null;
String options="0123456789ABCDEFGHIJ";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) this.findViewById(R.id.Button01);
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
cpd.show();
}
});
cpd= new CharacterPickerDialog(this, new View(this), null,options,false)
{
public void onClick(View v)
{
Toast.makeText(getApplicationContext(),"onClick! " + ((Button) v).getText().toString(),
Toast.LENGTH_SHORT).show();
dismiss();
}
public void onItemClick(AdapterView parent, View view, int position, longid)
{
String message = ("onItemClick! " + ((Button) view).getText().toString())
+ " position=" + position + " id=" + id;
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
dismiss();
}
};
}
}
No comments:
Post a Comment