TroothHertz
TroothHertz

Reputation: 186

Android No Grammar Constraints Droid Schema site down

I'm building a tab layout app consisting of 3 tabs. two of the tabs work fine and the third worked up until I implemented a switch-case, maybe unrelated, upon running the program it just errors when trying to access that tab in the emulator. Usually this seems to be an xml issue

However, my xml seems to be spotless, I did notice a yellow flag pointing to schemas, which won't go away, I've tried ignore etc. Some more digging suggests it could be because the schema site is down, I tried to access the site and can't so maybe it's down again???

anyway, I was wondering if this is whats causing my problem. Seems unlikely since the other two activity classes for the other two tabs work fine, just this one doesn't.

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


    <EditText android:text="" android:id="@+id/etInput"
        android:layout_width="fill_parent" android:layout_height="wrap_content" />

    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="horizontal">

        <TextView android:id="@+id/textView1" android:text="Gravity"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_weight="50" android:gravity="center" />
        <TextView android:id="@+id/textView2" android:layout_height="wrap_content"
            android:layout_width="wrap_content" android:text="Style"
            android:layout_weight="50" android:gravity="center" />

    </LinearLayout>


    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="horizontal">
        <RadioGroup android:id="@+id/rgGrav" android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="50">


            <RadioButton android:text="Left" android:id="@+id/rbLeft"
                android:layout_width="fill_parent" android:layout_height="wrap_content" />
            <RadioButton android:text="Centre" android:id="@+id/rbCentre"
                android:layout_width="fill_parent" android:layout_height="wrap_content" />
            <RadioButton android:text="Right" android:id="@+id/rbRight"
                android:layout_width="fill_parent" android:layout_height="wrap_content" />
        </RadioGroup>

        <RadioGroup android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="50">

            <RadioButton android:text="Normal" android:id="@+id/rbNormal"
                android:layout_width="wrap_content" android:layout_height="wrap_content" />
            <RadioButton android:text="Bold" android:id="@+id/rbBold"
                android:layout_width="wrap_content" android:layout_height="wrap_content" />
            <RadioButton android:text="Italics" android:id="@+id/rbItalics"
                android:layout_width="wrap_content" android:layout_height="wrap_content" />
        </RadioGroup>
    </LinearLayout>

    <TextView android:textSize="20dp" android:text="Enter some text and click"
        android:id="@+id/tvGetInput" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:gravity="center" />
    <Button android:layout_height="wrap_content" android:text="Ok" android:id="@+id/btnOK" android:layout_width="fill_parent"></Button>



</LinearLayout>

logcat copypasta (first time doing this, I don't think im doing it right)

10-23 20:45:09.716: ERROR/AndroidRuntime(2951): FATAL EXCEPTION: main
10-23 20:45:09.716: ERROR/AndroidRuntime(2951): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.b00517566.helloworldplus/com.b00517566.helloworldplus.RadioBtnsTab}: java.lang.NullPointerException
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.widget.TabHost.setCurrentTab(TabHost.java:323)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:129)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:453)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.view.View.performClick(View.java:2408)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.view.View$PerformClick.run(View.java:8816)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.os.Handler.handleCallback(Handler.java:587)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.os.Looper.loop(Looper.java:123)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.app.ActivityThread.main(ActivityThread.java:4627)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at java.lang.reflect.Method.invokeNative(Native Method)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at java.lang.reflect.Method.invoke(Method.java:521)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at dalvik.system.NativeStart.main(Native Method)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951): Caused by: java.lang.NullPointerException
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at com.b00517566.helloworldplus.RadioBtnsTab.onCreate(RadioBtnsTab.java:24)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-23 20:45:09.716: ERROR/AndroidRuntime(2951):     ... 18 more

edit 3

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        gravOne = (RadioGroup) findViewById(R.id.rgGrav);
        gravOne.setOnCheckedChangeListener(this);

        // textview = new TextView(this);
        //textview.setText("This is the Radio Buttons tab");
        //setContentView(textview);

        setContentView(R.layout.radiobtns_tab);

        textOutput = (TextView) findViewById(R.id.tvGetInput);
        getInput = (EditText) findViewById(R.id.etInput);

        Button ok =(Button) findViewById(R.id.btnOK);
        ok.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                textOutput.setText(getInput.getText());
            }
        });



    }

line 24 gravOne.setOnCheckedChangeListener(this);

Upvotes: 0

Views: 1022

Answers (1)

skynet
skynet

Reputation: 9908

Your XML file seems to compile fine. Don't worry about that warning, it is harmless and a known issue. Could you post the logcat output when you get the force close?

Okay, the part of the stack trace that says Caused by: java.lang.NullPointerException points you where you need to look. Can you post the onCreate method of your RadioBtnsTab class, as well as line 24 on its own? That is where the problem lies.

The problem is, you never call setContentView(R.layout.yourTabLayout). That is why gravOne is null. Try setting the content view and see if that works.

Upvotes: 3

Related Questions