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 982265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:40:11+00:00 2026-05-16T04:40:11+00:00

So, i’m trying to start activity by sweeping across the screen, it works fine

  • 0

So, i’m trying to start activity by sweeping across the screen, it works fine for all the other screens, just this screen that doesn’t fire the onTouch at all? Would you mind helping me? I’ve tried debugging it and still have no idea at all. Below are the codes, sorry for not putting snippets only as I thought I might did something wrong elsewhere

Btw, I’m also looking for advice on implementing sweeping to change screen. I’ve read about ViewFlipper and I know it will work very well, but I’ve around 8 screens with different backend coding needed. Anyways, I really need advice on this.

Thanks alot!!

Alvin

<?xml version="1.0" encoding="utf-8"?>

    <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:textSize="20dip"
            android:padding="5dip" android:textStyle="bold" android:text="@string/skills" />

    <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:padding="5dip"
            android:textSize="12dip" android:layout_marginLeft="10dip"
            android:text="@string/proficiency" />

    <LinearLayout android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="horizontal"
            android:gravity="center">
            <Button android:id="@+id/cSharp" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/cSharp" />
            <Button android:id="@+id/cLang" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/cLang" />
            <Button android:id="@+id/visualC" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/visualC" />
            <Button android:id="@+id/java" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/java" />
            <Button android:id="@+id/vb" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/vb" />
    </LinearLayout>

    <LinearLayout android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="horizontal"
            android:gravity="center">
            <Button android:id="@+id/perl" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/perl" />
            <Button android:id="@+id/win" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/win" />
            <Button android:id="@+id/unix" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/unix" />
            <Button android:id="@+id/linux" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/linux" />
            <Button android:id="@+id/php" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/php" />
    </LinearLayout>

    <LinearLayout android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="horizontal"
            android:gravity="center">
            <Button android:id="@+id/oracle" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/oracle" />
            <Button android:id="@+id/mysql" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/mysql" />
            <Button android:id="@+id/mssql" android:layout_height="60dip"
                    android:layout_width="80dip" android:text="@string/mssql" />
    </LinearLayout>

    <LinearLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:padding="5dip"
            android:orientation="horizontal" android:gravity="bottom|right">
            <ImageButton android:id="@+id/skillsPrevious"
                    android:layout_width="wrap_content" android:layout_height="wrap_content"
                    android:background="@null" android:paddingRight="3dip" android:src="@drawable/left" />
            <ImageButton android:id="@+id/skillsNext"
                    android:layout_width="wrap_content" android:layout_height="wrap_content"
                    android:background="@null" android:src="@drawable/right" />
    </LinearLayout>

    private float oldTouchValue;
    private FormDbAdapter mDbHelper;
    private Long mRowId;
    private Button cSharp, cLang, visualC, java, vb, perl, win, unix;
    private Button linux, php, oracle, mysql, mssql;
    private ImageButton nextButton, previousButton;
    private LinearLayout skillsView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            mDbHelper = new FormDbAdapter(this);
            mDbHelper.open();
            setContentView(R.layout.skills);

            cSharp = (Button)findViewById(R.id.cSharp);
            cLang = (Button)findViewById(R.id.cLang);
            visualC = (Button)findViewById(R.id.visualC);
            java = (Button)findViewById(R.id.java);
            vb = (Button)findViewById(R.id.vb);
            perl = (Button)findViewById(R.id.perl);
            win = (Button)findViewById(R.id.win);
            unix = (Button)findViewById(R.id.unix);
            linux = (Button)findViewById(R.id.linux);
            php = (Button)findViewById(R.id.php);
            oracle = (Button)findViewById(R.id.oracle);
            mysql = (Button)findViewById(R.id.mysql);
            mssql = (Button)findViewById(R.id.mssql);

            nextButton = (ImageButton)findViewById(R.id.skillsNext);
            previousButton = (ImageButton)findViewById(R.id.skillsPrevious);

            skillsView = (LinearLayout)findViewById(R.id.skillsView);

            mRowId = (savedInstanceState == null)? null:
                    (Long)savedInstanceState.getSerializable(FormDbAdapter.KEY_ID);
            if(mRowId == null){
                    Bundle extras = getIntent().getExtras();
                    mRowId = extras.getLong(FormDbAdapter.KEY_ID);
            }

            populateFields();

            nextButton.setOnClickListener(onClick);
            previousButton.setOnClickListener(onClick);

            cSharp.setOnClickListener(onClick);
            cLang.setOnClickListener(onClick);
            visualC.setOnClickListener(onClick);
            java.setOnClickListener(onClick);
            vb.setOnClickListener(onClick);
            perl.setOnClickListener(onClick);
            win.setOnClickListener(onClick);
            unix.setOnClickListener(onClick);
            linux.setOnClickListener(onClick);
            php.setOnClickListener(onClick);
            oracle.setOnClickListener(onClick);
            mysql.setOnClickListener(onClick);
            mssql.setOnClickListener(onClick);

            skillsView.setOnTouchListener(new View.OnTouchListener() {

                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                            // TODO Auto-generated method stub
                            switch(event.getAction()){
                            case MotionEvent.ACTION_DOWN:
                                    oldTouchValue = event.getX();
                                    break;
                            case MotionEvent.ACTION_UP:
                                    if(event.getX() - oldTouchValue < -200){
                                            createIntent(true);
                                            return true;
                                    }else if(event.getX() - oldTouchValue > 200){
                                            createIntent(false);
                                            return true;
                                    }
                            }
                            return false;
                    }
            });
    }

    protected View.OnClickListener onClick = new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                    // TODO Auto-generated method stub
                    switch(v.getId()){
                    case R.id.skillsNext:
                            createIntent(true);
                            break;
                    case R.id.skillsPrevious:
                            createIntent(false);
                            break;
                    default:
                            addSkillDialog(v.getId());
                    }
            }
    };

    /** direction = true => next page
     *  direction = false => previous page*/
    protected void createIntent(boolean direction){
            if(direction){
                    Intent i = new Intent();
                    i.putExtra(FormDbAdapter.KEY_ID, mRowId);
                    i.setClass(skills.this, languages.class);
                    startActivityForResult(i, 0);
            }else{
                    setResult(RESULT_OK);
                    finish();
            }
    }

    /** Create custom dialog for user to input skills info.
     * @param id: id of the button clicked by user. */
    protected void addSkillDialog(int id) {
            // TODO Auto-generated method stub
            final Button button = (Button)findViewById(id);

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            AlertDialog alertDialog;

            LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
            final View layout = inflater.inflate(R.layout.skillsdialog,
                            (ViewGroup)findViewById(R.id.skillsDialogId));

            builder.setView(layout);

            final RadioGroup radioExp = (RadioGroup)layout.findViewById(R.id.radioExp);
            final RadioGroup radioPro = (RadioGroup)layout.findViewById(R.id.radioPro);

            Cursor c = mDbHelper.fetchSkills(mRowId, button.getId());
            if(c.moveToFirst()){
                    startManagingCursor(c);
                    if(c.getString(c.getColumnIndexOrThrow(FormDbAdapter.KEY_SKILL_YEARS)).equals("0")){
                            radioExp.check(R.id.zeroYear);
                    }else if (c.getString(c.getColumnIndexOrThrow(FormDbAdapter.KEY_SKILL_YEARS)).equals("1-2")){
                            radioExp.check(R.id.onetotwo);
                    }else if (c.getString(c.getColumnIndexOrThrow(FormDbAdapter.KEY_SKILL_YEARS)).equals("3-4")){
                            radioExp.check(R.id.threetofour);
                    }else{
                            radioExp.check(R.id.five);
                    }

                    if(c.getString(c.getColumnIndexOrThrow(FormDbAdapter.KEY_SKILL_PRO)).equals("B")){
                            radioPro.check(R.id.B);
                    }else if(c.getString(c.getColumnIndexOrThrow(FormDbAdapter.KEY_SKILL_PRO)).equals("I")){
                            radioPro.check(R.id.I);
                    }else{
                            radioPro.check(R.id.A);
                    }
            }

            builder.setTitle(button.getText().toString())
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            String years = null;
                            String pro = null;
                            int expId = radioExp.getCheckedRadioButtonId();
                            int proId = radioPro.getCheckedRadioButtonId();

                            switch(expId){
                            case R.id.zeroYear:
                                    years = "0";
                                    break;
                            case R.id.onetotwo:
                                    years = "1-2";
                                    break;
                            case R.id.threetofour:
                                    years = "3-4";
                                    break;
                            case R.id.five:
                                    years = ">5";
                            }

                            switch(proId){
                            case R.id.B:
                                    pro = "B";
                                    break;
                            case R.id.I:
                                    pro = "I";
                                    break;
                            case R.id.A:
                                    pro = "A";
                            }

                            mDbHelper.newSkill(mRowId, button.getId(), pro, years);
                            button.setTypeface(Typeface.DEFAULT_BOLD);
                    }
            })
            .setNeutralButton("Undo Selection", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            mDbHelper.deleteSkill(mRowId, button.getId());
                            button.setTypeface(Typeface.DEFAULT);
                    }
            })
            .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            dialog.cancel();
                    }
            });

            alertDialog = builder.create();
            alertDialog.show();
    }

    /** Populate the fields in View if existed in database. */
    protected void populateFields(){
            Cursor c = mDbHelper.fetchAllSkills(mRowId);
            while (c.moveToNext()){
                    startManagingCursor(c);
                    Button skillBtn = (Button)findViewById(c.getInt(c.getColumnIndexOrThrow(FormDbAdapter.KEY_SKILL_NAME)));
                    skillBtn.setTypeface(Typeface.DEFAULT_BOLD);
            }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            // TODO Auto-generated method stub
            super.onActivityResult(requestCode, resultCode, data);
            switch (resultCode){
            case MainPage.ACTIVITY_BACK:
                    populateFields();
                    break;
            case MainPage.ACTIVITY_DONE:
                    setResult(MainPage.ACTIVITY_DONE);
                    finish();
            }
    }

    @Override
    protected void onResume() {
            // TODO Auto-generated method stub
            super.onResume();
            populateFields();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
            // TODO Auto-generated method stub
            super.onSaveInstanceState(outState);
            outState.putSerializable(FormDbAdapter.KEY_ID, mRowId);
    }
  • 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-05-16T04:40:11+00:00Added an answer on May 16, 2026 at 4:40 am

    You can use GestureDetector (Which is a better way to detect swipes) to detect swipes on your activities. Please find below link which shows how to implement it. The issue with your code which I feel is that apart from container control(LinearLayout in your case) you need to register the TouchListerner for all the controls also.

    Fling gesture detection on grid layout

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.