C
C
Chvalov2015-10-08 11:43:02
Android
Chvalov, 2015-10-08 11:43:02

When switching to the second activity, there are no elements, how so?

MainActivity.java from it I go to another activity:

if (id == R.id.action_settings) {
            Intent intent = new Intent(this, ControllerSettings.class);
            startActivity(intent);
            return true;
        }

Manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ua.com.ovis.andrey.calibrationforsensors" >

    <uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            </intent-filter>

            <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
                android:resource="@xml/device_filter" />

        </activity>

        <activity android:name=".ControllerSettings"
            android:label="@string/app_name_controller_settings">
        </activity>

    </application>

</manifest>
XML of the second activity
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".ControllerSettings">

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView"
        android:layout_alignParentEnd="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_above="@+id/button">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/SettingsParam">

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/SetNumDevice">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/TV_NumDevice"
                    android:id="@+id/TV_NumDevice" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="number"
                    android:ems="10"
                    android:id="@+id/editText" />
            </LinearLayout>

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/SetBaudrate"></LinearLayout>

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/SetReadMS"></LinearLayout>

        </LinearLayout>
    </ScrollView>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>
4f276c02f2ec4e6680b94ffed6c7d39f.png
ControllerSettings.java code
package ua.com.ovis.andrey.calibrationforsensors;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class ControllerSettings extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

}
And here is my output:
a609f1eb900f43ea98bf56e747527bd6.pngWhat is the problem and how to solve it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2015-10-08
@Chvalov

Forgot to call in the second activity
setContentView(R.layout.%название_xml_файла%);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question