0

OnClick of search button i am trying to launch a new activity

  • well this code was working few weeks ago, all of sudden giving errors.
  • How can i clear this

AndroidTabRestaurantDescListView.java

public class AndroidTabRestaurantDescListView extends TabActivity {

    // TabSpec Names
    private static final String INBOX_SPEC = "Rating";
    private static final String OUTBOX_SPEC = "Price";
    private static final String PROFILE_SPEC = "Distance";

    Button Photos;
    Button Filter;
    Button Search;
    Button Account;

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

        Photos=(Button) findViewById(R.id.PhotoButton); 
        Filter=(Button) findViewById(R.id.FilterButton);
        Search=(Button) findViewById(R.id.SearchBottomBarID);
        Account=(Button) findViewById(R.id.AccountBottomBarID);

        TabHost tabHost = getTabHost();

        // Inbox Tab
        TabSpec inboxSpec = tabHost.newTabSpec(INBOX_SPEC);
        Intent inboxIntent = new Intent(this, MainActivity.class);
        inboxSpec.setIndicator(INBOX_SPEC);
        // Tab Content
        inboxSpec.setContent(inboxIntent);

        // Outbox Tab
        TabSpec PriceSpec = tabHost.newTabSpec(OUTBOX_SPEC);
        Intent PriceIntent = new Intent(this, PriceDescriptionActivity.class);
        PriceSpec .setIndicator(OUTBOX_SPEC);
        PriceSpec.setContent(PriceIntent);

        // Profile Tab
        TabSpec DistanceSpec = tabHost.newTabSpec(PROFILE_SPEC);
        Intent DistanceIntent = new Intent(this, DistanceDiscriptionActivity.class);
        DistanceSpec .setIndicator(PROFILE_SPEC); 
        DistanceSpec.setContent(DistanceIntent);

        // Adding all TabSpec to TabHost
        tabHost.addTab(inboxSpec); 
        tabHost.addTab(PriceSpec); 
        tabHost.addTab(DistanceSpec); 

        //Set the current value tab to default first tab
        tabHost.setCurrentTab(0);

        //Setting custom height for the tabs
        final int height = 45;
        tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = height;
        tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = height;
        tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = height;




        Photos.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent PhotoIntent=new Intent(AndroidTabRestaurantDescListView.this,AndroidTabRestaurantDescImageListView.class);
                startActivity(PhotoIntent);

            }
        });


        Filter.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent FilterIntent=new Intent(AndroidTabRestaurantDescListView.this,Filters.class);
                startActivity(FilterIntent);
            }
        });


        Search.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent FilterIntent=new Intent(AndroidTabRestaurantDescListView.this,SearchPage.class);
                startActivity(FilterIntent);
            }
        });


        Account.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent PhotoIntent=new Intent(AndroidTabRestaurantDescListView.this,RestaurantAccount.class);
                startActivity(PhotoIntent);

            }
        });


    }

}

SearchPage.java

public class SearchPage extends FragmentActivity {

    EditText mEdit;
    EditText City;
    Button Back;
    Button Search;


    private RadioGroup rdg;
    private RadioButton breakFast;
    private RadioButton lunch;
    private RadioButton dinner;


    private String selectedType="";



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

        City=(EditText) findViewById(R.id.CITY_ID);


        rdg = (RadioGroup) findViewById(R.id.radioGroup1);
        breakFast = (RadioButton) findViewById(R.id.BreakfastRG_ID);
        lunch = (RadioButton) findViewById(R.id.LunchRG_ID);
        dinner = (RadioButton) findViewById(R.id.DinnerRG_ID);
        breakFast.setSelected(true);

        rdg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if(i==R.id.BreakfastRG_ID){
                    selectedType = breakFast.getText().toString();
                }else if(i==R.id.LunchRG_ID){
                    selectedType = lunch.getText().toString();
                }else{
                    selectedType = dinner.getText().toString();
                }
            }
        });

        Back=(Button) findViewById(R.id.TopNavigationBarRestaurantSearchActivityBackButton);
        Back.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                 finish();
            }
        });

        Search=(Button) findViewById(R.id.SEARCH_BUTTON_ID);
        Search.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                Intent searchIntent=new Intent(SearchPage.this,AndroidTabRestaurantDescSearchListView.class);
                searchIntent.putExtra("REST",City.getText().toString());
                searchIntent.putExtra("REST1",selectedType);
                Log.i ("REST-IN-SEARCHPAGE", City.toString ());
                Log.i ("TYPE-IN-SEARCHPAGE", selectedType.toString ());
                startActivity(searchIntent);
            }
        });


    }

    public void selectDate(View view) {
        DialogFragment newFragment = new SelectDateFragment();
        newFragment.show(getSupportFragmentManager(), "DatePicker");
    }
    public void populateSetDate(int year, int month, int day) {
        mEdit = (EditText)findViewById(R.id.DATE_EDIT_TEXT_ID);
        mEdit.setText(day+"/"+month+"/"+year);
    }
    public class SelectDateFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            final Calendar calendar = Calendar.getInstance();
            int yy = calendar.get(Calendar.YEAR);
            int mm = calendar.get(Calendar.MONTH);
            int dd = calendar.get(Calendar.DAY_OF_MONTH);
            return new DatePickerDialog(getActivity(), this, yy, mm, dd);
        }

        public void onDateSet(DatePicker view, int yy, int mm, int dd) {
            populateSetDate(yy, dd, mm+1);
        }
    }
}

log::

12-26 11:43:06.243: E/AndroidRuntime(506): Uncaught handler: thread main exiting due to uncaught exception
12-26 11:43:06.253: E/AndroidRuntime(506): java.lang.NoClassDefFoundError: com.project.findmybuffet.SearchPage
12-26 11:43:06.253: E/AndroidRuntime(506):  at com.project.findmybuffet.AndroidTabRestaurantDescListView$3.onClick(AndroidTabRestaurantDescListView.java:101)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.View.performClick(View.java:2364)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.View.onTouchEvent(View.java:4179)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.widget.TextView.onTouchEvent(TextView.java:6541)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.View.dispatchTouchEvent(View.java:3709)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
12-26 11:43:06.253: E/AndroidRuntime(506):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
12-26 11:43:06.253: E/AndroidRuntime(506):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
12-26 11:43:06.253: E/AndroidRuntime(506):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.os.Looper.loop(Looper.java:123)
12-26 11:43:06.253: E/AndroidRuntime(506):  at android.app.ActivityThread.main(ActivityThread.java:4363)
12-26 11:43:06.253: E/AndroidRuntime(506):  at java.lang.reflect.Method.invokeNative(Native Method)
12-26 11:43:06.253: E/AndroidRuntime(506):  at java.lang.reflect.Method.invoke(Method.java:521)
12-26 11:43:06.253: E/AndroidRuntime(506):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
12-26 11:43:06.253: E/AndroidRuntime(506):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12-26 11:43:06.253: E/AndroidRuntime(506):  at dalvik.system.NativeStart.main(Native Method)

note:: I have declared both activities in manifest


smriti3
  • 871
  • 2
  • 15
  • 35

3 Answers3

1
12-26 11:43:06.253: E/AndroidRuntime(506): java.lang.NoClassDefFoundError: com.project.findmybuffet.SearchPage
12-26 11:43:06.253: E/AndroidRuntime(506):  at com.project.findmybuffet.AndroidTabRestaurantDescListView$3.onClick(AndroidTabRestaurantDescListView.java:101)

It is unable to find com.project.findmybuffet.SearchPage class. Please check your package name once.

<activity android:name="com.project.findmybuffet.SearchPage" >
        </activity>

You have mentioned your search page activity in this path "com.project.findmybuffet.SearchPage" so please check whether that SearchPage.class is in that path or not. If everything is good. Try clean your project and run again

Now try this

Photos.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent photoIntent=new Intent(AndroidTabRestaurantDescListView.this,AndroidTabRestaurantDescImageListView.class);
                startActivity(photoIntent);

            }
        });


        Filter.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent filterIntent=new Intent(AndroidTabRestaurantDescListView.this,Filters.class);
                startActivity(filterIntent);
            }
        });


        Search.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent searchIntent=new Intent(AndroidTabRestaurantDescListView.this,SearchPage.class);
                startActivity(searchIntent);
            }
        });


        Account.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent accountIntent=new Intent(AndroidTabRestaurantDescListView.this,RestaurantAccount.class);
                startActivity(accountIntent);

            }
        });
saa
  • 1,538
  • 2
  • 17
  • 35
  • Did you try cleaning project – saa Dec 26 '13 at 06:54
  • Ok... close your eclipse. Copy your project. Delete this project from your workspace. Now delete following files from your project .classPath, .project, project.properties. Then import your project into workspace. You will get fresh project. – saa Dec 26 '13 at 07:01
  • So you will get fresh project. Import it and run it. Hopes it will work. Otherwise let me know – saa Dec 26 '13 at 07:08
  • I did as u told but now R.java is not getting generated :( – smriti3 Dec 26 '13 at 07:15
  • THat is common issue. clean your project – saa Dec 26 '13 at 07:20
  • Ohh... ok.please wait. I will verify your code again. I ll get back you. – saa Dec 26 '13 at 08:23
  • remain buttons (photos, filter,..) working normally? or giving error? – saa Dec 26 '13 at 08:25
  • Please post 101 line i.e 12-26 11:43:06.253: E/AndroidRuntime(506): at com.project.findmybuffet.AndroidTabRestaurantDescListView$3.onClick(AndroidTabRestaurantDescListView.java:101) – saa Dec 26 '13 at 08:32
  • line 101 is : Intent FilterIntent=new Intent(AndroidTabRestaurantDescListView.this,SearchPage.class); – smriti3 Dec 26 '13 at 08:35
  • It has to do something with this error ............. 12-26 14:19:03.130: E/dalvikvm(813): Could not find class 'com.project.findmybuffet.SearchPage', referenced from method com.project.findmybuffet.AndroidTabRestaurantDescListView$3.onClick – smriti3 Dec 26 '13 at 08:50
  • look at this post. It may helpful to you http://stackoverflow.com/questions/9859899/activitynotfoundexception-on-fragmentactivity – saa Dec 26 '13 at 08:57
  • I resolved it ... i used this link http://stackoverflow.com/a/16603954/2901850 ........ i selected all the check box .... now the error is resolved – smriti3 Dec 26 '13 at 08:58
  • Dont mind... what was the problem exactly? how did you resolve it – saa Dec 26 '13 at 09:01
  • hi smriti3.. Please uncheck this post as correct answer. Because my answer is not correct for your problem. Thanks in advance.. :) – saa Dec 26 '13 at 09:07
  • @ saa .... thanks for your help ... your debugging tips is a good learning experience for me .... i have shared my answer .... have a look here http://stackoverflow.com/a/20782073/2901850 (i have answered as a ans to my question) ... thanks :) – smriti3 Dec 26 '13 at 09:13
1

I Used this link to resolve the solution & ansewr of saa also helped

i just selected all the options in the screenshot below

enter image description here enter image description here

Community
  • 1
  • 1
smriti3
  • 871
  • 2
  • 15
  • 35
0

The error you are getting acoording to the log is a problem concerning ClassPaths.

Read here

Community
  • 1
  • 1
gilonm
  • 1,829
  • 1
  • 12
  • 22