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

  • SEARCH
  • Home
  • 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 8859701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:07:39+00:00 2026-06-14T15:07:39+00:00

im new to android programming. im wondering if it is possible to generate ID

  • 0

im new to android programming.

im wondering if it is possible to generate ID i created in java class to r.java

The ID i want to generate is nBtnLayoutlist.

public class classABC extends Activity {
    private int nBtnLayoutlist = 20;

    private OnClickListener onClick() {
        return new OnClickListener() {

            public void onClick(View v) {

            nBtnLayout = (LinearLayout)findViewById(R.id.nBtnLayoutList);

            }
        };
    }

    private LinearLayout newBtnLayout(){
    LinearLayout nBtnLayout = new LinearLayout(this);
    final LayoutParams lparams = new LayoutParams(LayoutParams.MATCH_PARENT,       LayoutParams.WRAP_CONTENT);
    nBtnLayout.setOrientation(LinearLayout.VERTICAL);
    nBtnLayout.setLayoutParams(lparams); 
    nBtnLayout.setWeightSum(100);
    nBtnLayout.setId(nBtnLayoutList);
    return nBtnLayout;

}
  • 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-14T15:07:40+00:00Added an answer on June 14, 2026 at 3:07 pm

    The ids in R.java are generated at build time from the contents of your .xml files. R.java cannot be modified by hand and it cannot be modified at run time.

    If you want, you can define an id resource by declaring it in some file in res/values (the file can have any name):

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <item
            type="id"
            name="id_name" />
    </resources>
    

    You can always set the id of a view in your layout by calling setId(int) (as you are already doing).

    EDIT: If you want to use a constant in the call such as

    nBtnLayout.setId(nBtnLayoutList);
    

    then you need to use the same constant in calls such as

    nBtnLayout = (LinearLayout)findViewById(nBtnLayoutList); // NOT R.id.nBtnLayoutList
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new with Android programming. I'm just wondering whether its possible to set up
I am new to Android and Java Programming and I want to ask if
I am fairly new to Android programming and was wondering how I can get
I'm pretty new to Android programming so bear with me. I was wondering if
New to android programming. Getting Following error. 04-07 14:49:05.452: ERROR/AndroidRuntime(1566): FATAL EXCEPTION: main java.lang.OutOfMemoryError
i am new to android programming and i want to create an api with
I am new to Android programming, but not to programming in general or Java.
I am new to android programming and trying to build a map activity app.
I'm still new in android programming, what I'm trying to do is, I want
I'm new to Android programming however I do have some Java experience. What I

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.