Can I simulate the key event on the emulator?

by Steven Ho » Mon, 03 Nov 2008 14:20:41 GMT

Sponsored Links
 Hi all,
    I want to simulate the key press function. Is there any way to do it? the 
keys like dialing , hangup or number bottons. Hope your reply. Thanks!
Steven Ho

Other Threads

1. Custom Compound Control

I'm trying to learn how to build my own custom compound control
component by reading:

I created my own view class and inherited it from RelativeLayout like

public class MyCompoundView extends RelativeLayout

I also wrote a constructor like so:

// Constructor version for instantiation from XML layout file.

public MyCompoundView(Context context, AttributeSet attrs)
        super(context, attrs);

and created an main.xml file that uses it:


Everything works fine.  What I can't figure out is how to get access
to the attributes in the xml to read the hello string so I can display
it.  I can't find an example of someone doing this that works for

The LabelView from the ApiDemos does something that looks good:

But when I try to modify this for my program as shown here:

text_ = new TextView(context);

TypedArray a = context.obtainStyledAttributes(attrs,

CharSequence s = a.getString(R.styleable.MyCompoundView_text);
if (s != null) {

I get the compiler error:  R.styleable cannot be resolved.

So I tried to use this instead:

// see:

LayoutInflater inflater = (LayoutInflater) context.getSystemService
inflater.inflate(R.layout.my_layout, this);

I get the compiler error:  R.layout cannot be resolved.

I'd like to be able to share my composite control with others, so I'd
want it to be flexible in that I can define my own attributes.  Also,
it should allow users to declare the control in XML and not just
instantiate it in Java code.

Any hints on how to do this?




2. Creating mutable Bitmap directly from a File - performance?

Hi there!

I am using the Canvas class to draw things onto existing images.
Right now I am using the following code:

// File is a JPG file, e.g. "example.jpg"
Bitmap immutableBitmap = BitmapFactory.decodeFile(file.getAbsolutePath
Bitmap b = immutableBitmap.copy(Bitmap.Config.ARGB_8888, true);
immutableBitmap = null;

Canvas c = new Canvas(b);
Paint p = new Paint();
// drawing starts here

As you can see I first read a bitmap from a file, just to create a
mutable copy of it in the next step. But isn't this a huge lack of
performance? Wouldn't it be better to create a mutable bitmap
directly? And how may I achieve this, if possible?

Thanks in advance & regards

Marc Reichelt   ||


3. Chess Walk

4. Googlewave-Bos Wilber

5. does XT9 keyboard support in Android 2.0?

6. Managing receiving/making calls with MediaPlayer

7. Join here