Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8497163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:03:13+00:00 2026-06-11T00:03:13+00:00

I wrote an app with 1 activity and 1 view, so it gives me

  • 0

I wrote an app with 1 activity and 1 view, so it gives me the coordinates of my fingers i put on the screen. Worked perfectly.

The Problem is now: I Created a new App with more than 1 Activity so i can change between them with intents. also worked fine. But one Activity should be the one wich give me my finger positions. So i Copyed the class and activity put them into the manifest. And made a Button and a intend for to run it.
So when i try to run it it creates the class but doesnt react on my onTouchEvents anymore…
and i have no clue why. i hope i explained my problem well enough for u guys to understand.

So this is my main activity. starts the menu with the option to go to the not working class

public class V1_2 extends Activity implements OnClickListener{
    Button btn_1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_v1_2);

        btn_1 = (Button) findViewById(R.id.button1);
        btn_1.setOnClickListener(this);

    }

    public void onClick(View v) {
        if( btn_1.getId() == ((Button)v).getId() ){
            startActivity(new Intent(this,Obj_recog.class));
        }
    }

This is now the activity wich creates the touchpiont class for the touchevents

public class Obj_recog extends Activity implements OnClickListener{
    touchtest TP;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.blank);
        TP = new touchtest(this);
    }

    public void onClick(View v) {

    }

And now an example of what doesnt work here but worked at the last project the same way

public class touchtest extends View{

    public touchtest(Context context) {
        super(context);
        Log.d("worked", "worked");

    }
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        Log.d("Touch", "TOUCH!!!!");
        return true;
    }

}

So i get the message that it “worked” but it doesnt react on touchevents like it used to do…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:03:15+00:00Added an answer on June 11, 2026 at 12:03 am

    It will be worked if you add touchtest view as your main view by using setcontentview and then
    add touchlistener on that view and call your ontouchevent from your touchtest class. code will be like —

     TP = new touchtest(this);
        setContentView(TP);
        TP.setOnTouchListener(new View.OnTouchListener() {
    
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
    
                                TP.onTouchEvent(event);
    
                return false;
            }
        });
    

    i think should change this approach find an alternative way to implement for which you are going in this way.

    In this way you can keep your blank layout and also TP.

    RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl);
    TP = new touchtest(this);
        rl.addView(TP);
    
        TP.setOnTouchListener(new View.OnTouchListener() {
    
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
    
                                TP.onTouchEvent(event);
    
                return false;
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building one app & this is the setting page(Activity view) of my
My app crashes when I try to launch a new activity. The stack trace
I wrote simple android app with bugs. When open second activity from menu- android
I wrote an app that implements a web server with multithreading. The main activity
I am new to Android programming and I wrote an app implementing only the
I wrote an app for image contest and what I am trying to achieve
I wrote an app and I want to sell it online, so I uploaded
I wrote an app that uses Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES) to find the folder to store
I wrote an app in C++, and downloaded some samples code from the internet
A while ago I wrote an app that relied on XML coming out of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.