简体   繁体   中英

R.java android lost

I lost R.java class when I clean my project. So please how can I get it back? Cause R.java define automatically in gen. Is there any way to do that?

I have imported a package to my project and I use it in project classes and pages but when I navigate to a page use a package the app gives a waiting and it still waiting.

How can I stop this problem and go to the next page?

public class HomePage extends Activity {    
    @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.person);
            Carousel car=(Carousel) findViewById(R.id.carousel);

            car.setOnItemClickListener(new OnItemClickListener(){

                public void onItemClick(CarouselAdapter<?> parent, View view,
                        int position, long id) {
                    // TODO Auto-generated method stub
                    if(position==0){
                        Intent i=new Intent(HomePage.this,StudentInformationActivity.class);

                        startActivity(i);
                        }else if(position==1){
                            Intent i=new Intent(HomePage.this,PersonalProfileActivity.class);
                            startActivity(i);
                        }

                }

            });
        }


    }

on this page that we used person as activities but it doesn't work.

Sometimes when you clean your project the R file disappears, I had the same issue.

The way I fixed it was:

  • Make sure all the import android.R was removed -Clean again (if this doesn't fix it, restart eclipse and try again)

Or

  • Put the pointers to R file in comment fe // setContentView(R.layout.main);
  • If all the pointers to R file are in comment, you should get only warnings in the file, and hopefully errors somewhere else.
  • Fix the errors and then uncomment the pointers. Sometimes eclipse ignores some errors and drops the R file and then says nothing about it, which is annoying, but this will fix it. :)

  • If this still doesn't work, you can try create a new project and copy paste your code in it.

Just Save the XML Layout file and It will automatically generate the new R file. But make sure at first that the file does not contain any errors.

About the second Question, I'm not sure that I got it will. I think you mean you can not refer to the PersonalProfileActivity.class in this activity. Make sure that you imported the package contains this class if it is in another package. Also do not forget to add it to your manifest file.

Could be errors in your xml files. Correct the errors and clean the project. It will come back!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM