I am working on a project based on Mapping the Remote control keys with android device.Here I can able to get the keycodes of Remote keys and return values for it based on the key codes.But the problem is, I don't know how to append the values inside the edit text.If I pressed the remote keys, it always returns numbers only.Guide me in a right way to make this work. Thanks in advance.
Sample Code:
I am having the below code in a Global Activity.And I extended all other Activities from this one.
public String switchedMethod(int key)
{
String letter = null;
switch(key)
{
case 9:
letter = "a";
break;
case 10:
letter = "b";
break;
case 11:
letter = "c";
break;
case 12:
letter = "d";
break;
case 13:
letter = "e";
break;
case 14:
letter = "f";
break;
case 15:
letter = "g";
break;
case 16:
letter = "h";
break;
}
Log.v("LETTER", ""+letter);
return letter;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
Log.v("KEYCODE", ""+keyCode);
switchedMethod(keyCode);
return super.onKeyDown(keyCode, event);
}
//Code Related to Edit Text
public class SettingsSubElementCreator extends GlobalActivity
{
protected void handleSDEditText(int optionItemsCurrentItemIndex)
{
LinearLayout subLayout = new LinearLayout(this);
subLayout.setOrientation(LinearLayout.VERTICAL);
subLayout.removeAllViews();
createButtons();
// I NEED TO APPEND THE TEXT FOR THE BELOW EDITTEXT VIEW
final EditText SDEditText = new EditText(this);
SDEditText.setTypeface(boldTypeface);
subLayout.addView(SDEditText);
subLayout.addView(okcancelButtonLayout);
final ModifySettingsDialog dialog = new ModifySettingsDialog(this,
R.string.video_aspect_adjustment_sd,
optionItemsCurrentItemIndex, subLayout, false);
dialog.show();
okButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
Toast.makeText(view.getContext(),"inside video aspect adjustment sd"+ SDEditText.getText(), Toast.LENGTH_LONG).show();
dialog.dismiss();
}
});
cancelButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
dialog.dismiss();
}
});
}