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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:27:20+00:00 2026-06-14T16:27:20+00:00

I have recently started working with android in eclipse. I have to keep within

  • 0

I have recently started working with android in eclipse. I have to keep within the Model-View-Controller (MVC) structure.

My goal is simply to display a rectangle box on screen. What I have got at the minute is a application that has four screens (main menu and the three other screens linked to it). The box implementation is for one of these three screens (board)

board.java code

package com.example.connectfour;

import com.example.connectfour.model.Gaps;
import com.example.connectfour.view.ConnectFourView;

imports[..]

public class Board extends Activity {

    private Button btnExit;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        connectfourView = new ConnectFourView(this);

        setContentView(R.layout.board);


        btnExit = (Button)findViewById(R.id.btn4);
        btnExit.setOnClickListener(new OnClickListener(){

            public void onClick(View v){
                Intent startMain = new Intent(Board.this, MainActivity.class);
                startActivity(startMain);
            }
        });
    }

}

board.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:background="#48D9AB">


        <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="Play"
        tools:context=".Board" />

            <Button 
        android:id="@+id/btn4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:text="Exit"        />
</RelativeLayout>

ConnectFourView.java code

package com.example.connectfour.view;

import com.example.connectfour.model.Gaps;

imports[..]

public class ConnectFourView extends View {
    public ConnectFourView(Context context) {
        super(context);
        setMinimumWidth(100);
        setMinimumHeight(20);
    }

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int width = Math.max(getSuggestedMinimumWidth(),widthMeasureSpec);
            int height = Math.max(getSuggestedMinimumHeight(), heightMeasureSpec);
            setMeasuredDimension(width, height);
    }


    protected void onDraw(Canvas canvas){
        canvas.drawColor(Color.WHITE);
    }

}

I have tried the following code in board.xml file which I believe would bring it all together however when a insert this it my application sends 30+ errors to logcat.

     <example.connectfour.view
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"/>

Note: As this is my first android post I am sorry in advance for any missing/additional code. Thanks you

EDIT for TanjaV. errors i get in logcat (these all appear when the above code is added to the board.xml file.

11-20 19:14:56.446: E/AndroidRuntime(630): FATAL EXCEPTION: main
11-20 19:14:56.446: E/AndroidRuntime(630): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.connectfour/com.example.connectfour.Board}: android.view.InflateException: Binary XML file line #23: Error inflating class com.example.connectfour.view.ConnectFourView
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.os.Looper.loop(Looper.java:123)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-20 19:14:56.446: E/AndroidRuntime(630):  at java.lang.reflect.Method.invokeNative(Native Method)
11-20 19:14:56.446: E/AndroidRuntime(630):  at java.lang.reflect.Method.invoke(Method.java:521)
11-20 19:14:56.446: E/AndroidRuntime(630):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-20 19:14:56.446: E/AndroidRuntime(630):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-20 19:14:56.446: E/AndroidRuntime(630):  at dalvik.system.NativeStart.main(Native Method)
11-20 19:14:56.446: E/AndroidRuntime(630): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class com.example.connectfour.view.ConnectFourView
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.view.LayoutInflater.createView(LayoutInflater.java:503)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-20 19:14:56.446: E/AndroidRuntime(630):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.app.Activity.setContentView(Activity.java:1647)
11-20 19:14:56.446: E/AndroidRuntime(630):  at com.example.connectfour.Board.onCreate(Board.java:28)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-20 19:14:56.446: E/AndroidRuntime(630):  ... 11 more
11-20 19:14:56.446: E/AndroidRuntime(630): Caused by: java.lang.NoSuchMethodException: ConnectFourView(Context,AttributeSet)
11-20 19:14:56.446: E/AndroidRuntime(630):  at java.lang.Class.getMatchingConstructor(Class.java:660)
11-20 19:14:56.446: E/AndroidRuntime(630):  at java.lang.Class.getConstructor(Class.java:477)
11-20 19:14:56.446: E/AndroidRuntime(630):  at android.view.LayoutInflater.createView(LayoutInflater.java:475)
11-20 19:14:56.446: E/AndroidRuntime(630):  ... 21 more
  • 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-14T16:27:21+00:00Added an answer on June 14, 2026 at 4:27 pm

    Discovered the answer. I was missing the below code in ConnectFourView.java

    public ConnectFourView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setMinimumWidth(100);
        setMinimumHeight(20);
    }
    

    Thanks to everyone who helped me discover this

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

Sidebar

Related Questions

I recently started working with Eclipse to build Android Applications. I have made a
I recently have started programming again for the android and am currently working on
I have recently started working with Android. I don't have that much experience with
I have recently started working with Android, And I need to draw a Circle
This is a very elementary I realize, I have recently started working with asp.net
i have recently started working on C# and i am very amateur at it
I have recently started working on an app which has both Java and native
I have recently started working on my master thesis in C that I haven't
I have recently started working in iOS Development, I have noticed the app size
I have recently started using doc-view in Emacs, but I am having quite a

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.