Android Studio, problems creating two screens

0

I searched google out and did not find a solution. I created two Actionviews through intent. And even one screen goes to the other. But the problem starts when I try to put functions on screen2. The application compiles but it hangs on the phone. I'm going to post the java code and the xmls code

screen1 java:

package com.example.luedry.teste.feature;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
public class MainActivity extends AppCompatActivity {


    public void irtela2 (View view){
        Intent tela2=new Intent(MainActivity.this,Tela2Activity.class);
        startActivity(tela2);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

screen1 xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/verde"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="377dp"
        android:layout_height="61dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView2"
            android:layout_width="180dp"
            android:layout_height="67dp"
            android:layout_weight="1"
            android:text="data"
            android:textColor="@color/branco"
            android:textSize="30sp"
            tools:layout_editor_absoluteX="19dp"
            tools:layout_editor_absoluteY="0dp" />

        <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/fundo"
            android:text="configurações"
            android:onClick="irtela2"
            android:textColor="@color/branco" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="112dp"
        android:orientation="vertical">

        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="Aplicativo mqtt banco de dados"
            android:textColor="@color/branco"
            android:textSize="30sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="90dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView4"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:textColor="@color/branco"
            android:textSize="30sp"
            android:text="valor da caixa" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="%s"
            android:textColor="@color/branco"
            android:textSize="30sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="575dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            app:srcCompat="@drawable/icone" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical"></LinearLayout>
    </LinearLayout>

</LinearLayout>

screen2 java:

package com.example.luedry.teste.feature;

import android.content.Intent;
import android.graphics.Color;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Tela2Activity extends AppCompatActivity  {

    public void voltartela1 (View view){
        Intent volta1=new Intent(Tela2Activity.this,MainActivity.class);
        startActivity(volta1);
    }


    Button musica;
    TextView txt;
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         musica= (Button) findViewById(R.id.customizar);
         txt=(TextView) findViewById(R.id.mudar);
         musica.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 txt.setBackgroundColor(Color.parseColor("@color/branco"));


             }
         });

    }



}

screen2 xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/verde"
    tools:context=".Tela2Activity">

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

        <TextView
            android:id="@+id/textView5"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="date"
            android:textColor="@color/branco"
            android:textSize="30sp" />

        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@color/fundo"
            android:text="return"
            android:onClick="voltartela1"
            android:textColor="@color/branco"
            android:textSize="20sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="55dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/mudar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Tela de configurações"
            android:textColor="@color/branco"
            android:textSize="30sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="124dp"
        android:orientation="vertical">

        <TextView
            android:id="@+id/textView7"
            android:layout_width="match_parent"
            android:layout_height="52dp"
            android:gravity="center"
            android:text="digite host,porta,nome,senha,topico"
            android:textColor="@color/branco"
            android:textSize="20sp" />

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/pega"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/branco"
                android:gravity="center"
                android:hint="hint" />

        </android.support.design.widget.TextInputLayout>

        <Button
            android:id="@+id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="enviar"
            android:background="@color/fundo"
            android:textColor="@color/branco"
            android:textSize="20sp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="28dp"
        android:orientation="horizontal"></LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="44dp"
        android:orientation="vertical">

        <Space
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <Button
            android:id="@+id/customizar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/fundo"
            android:text="musica"
            android:textColor="@color/branco"
            android:textSize="20sp" />

        <Space
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <Button
            android:id="@+id/button6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/fundo"
            android:text="vibrar"
            android:textColor="@color/branco"
            android:textSize="20sp" />

        <Space
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/icone" />
    </LinearLayout>
</LinearLayout>
    
asked by anonymous 09.08.2018 / 21:29

0 answers