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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:07:49+00:00 2026-06-16T09:07:49+00:00

I have a problem. I’d like to use layout for designe this ArcTimerActivity. When

  • 0

I have a problem. I’d like to use layout for designe this ArcTimerActivity.
When I change setContentView(cv) to setContentView(R.layout.arc_timer_activity) IT DOES NOT WORK. (I’m not programmer, so its not easy for me)

public class ArcTimerActivity extends Activity implements Runnable, View.OnClickListener, View.OnLongClickListener {

    private ArcTimerView cv = null;
    private Thread t = null;
    private boolean run_thread = false;
    private int run_thread_fps = 50; // Max 1000

    private IntervalSession is;

    private final int MENU_PREFERENCES = 15;

    //@Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);


        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        is = new IntervalSession();
        restorePreferences();

        cv = new ArcTimerView(this, is);

        cv.setOnClickListener(this);
        cv.setOnLongClickListener(this);

        restoreRunningState(getLastNonConfigurationInstance());

        setContentView(cv);
    }


   ....................

IF USE setContentView(R.layout.arc_timer_activity) – NO ERRORS, JUST Black SCREEN. Maby I need smth to add or change to display Activity in layout?

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
 android:layout_height="fill_parent"
android:orientation="vertical"

 >

 <View
android:layout_width="fill_parent"
android:layout_height="fill_parent"
></View>

  </LinearLayout>
  • 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-16T09:07:50+00:00Added an answer on June 16, 2026 at 9:07 am

    First give a specific id to any layout let say View in your xml file where you want to add that cv (or IntervalSession()).

    Now setContentView(R.layout.arc_timer_activity);

    Now, define object of Resource View like below:

         <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
     android:layout_height="fill_parent"
    android:orientation="vertical"
    
     >
    
     <View
    android:id="@+id/myView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    ></View>
    
      </LinearLayout>
    

    Now in Jva file give resources to that id

    View myView = (View) findViewById(R.id.myView);
    

    Now create object of the view you want to add.

    cv = new ArcTimerView(this, is);
    

    and add that to your View.

    myView.add(cv); // or myView.addView(cv);
    invalidate();
    

    This way you can add any view dynamically to your resource layout.

    Feel free for any comments.

    UPDATE

    There is one of my project Demo in which i have implemented as like your requirement. See code snippet below. MyView is the call to whom i have added. Concentrate on it.

     @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(new MyView(this)); // Edited
        statusString="testing Post For Application Development"; 
        setContentView(R.layout.main);
        display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        drawingLayout = (RelativeLayout)findViewById(R.id.drawingLayout);
        System.out.println("The Layout is: "+drawingLayout);
        myView = new MyView(this);
        drawingLayout.addView(myView);
    
        display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        // Setting mPaint 
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
        mPaint.setColor(0xFFFF0000);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setStrokeWidth(7);
    

    In above code, MyView is the class to whom i want to add in to the layout. Please refer that code and you will ge how i have add MyView class object in to the layout.

    Hope this code help you.

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

Sidebar

Related Questions

I have problem in my xampp server php file not work if I write
I have problem to make work a resource file. This is my simple code
I have problem with my query on C, I’m using the oci8 driver. This
I have problem SIMILAR to preventing form data reposting, but not quite the same
Have problem while getting data from Memcached on .NET MVC solution. I have this
I have problem, when converting Windows application from .NET2.0 to .NET3.5. I do this
Have problem with this code var MAIN_LOCATION = http://www.bosscaffe.com/new/; $(#gallery_page).click(function() { $('#gallery_photos').show(); getPhotos(); return
I have problem that in my MVC 3 project, the logon view do not
I have problem with importing jar file and running in Geany IDE . This
I have problem running a Java RCP application via Java Webstart. This works for

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.