开发者

onTouch event for analog clock

I am creating an app with an analog clock. If I touch the analog clock I want the next activity to be called. How do I do that?

I did the 开发者_StackOverflow社区following and I am struggling with onTouch. I imported the classes for view and analog clock and by call the instance variable time I do not get an onTouch or any function list. Please correct me.

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.widget.AnalogClock;


public class StartActivity extends Activity
{
    int width,height,orientation;
    AnalogClock time;

      @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);

            DisplayMetrics displaymetrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);

            height = displaymetrics.heightPixels;
            width = displaymetrics.widthPixels;

            Log.e("RA new activity", "Width = "+width+"Height = "+height+" orientation= "+orientation);

            setContentView(R.layout.startactivity);

            time =(AnalogClock)findViewById(R.id.widget44);

            try
            {

            }
            catch(Exception e)
            {
                Log.e("buttons","");
            }
            }

   time. // i do not get any function list.






}


Add this code after time =(AnalogClock)findViewById(R.id.widget44);

time.setOnClickListener(new View.OnClickListener() {

   @Override
   public void onClick(View v) {
      Intent intent = new Intent(StartActivity.this, NextActivity.class);
      startActivity(intent);
   }
};);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜