Макет инфлятора показывается пустым - PullRequest
0 голосов
/ 26 декабря 2018

Я новичок в разработке приложений для Android.Я пытался накачать макет для другого класса, например:

Пример:

class_ ----> activity_example_.xml

test1 class_ ----> test1.xml

Мне нужно что-то вроде этого

Пример:

class_ ----> test1.xml

Я попробовал этот код, и он показывает меня пустым (это мой код)

test1.xml

<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:id="@+id/linear"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/image3"
    tools:layout_editor_absoluteY="81dp">

    <TextView
        android:id="@+id/txt12"
        android:layout_width="150dp"
        android:layout_height="47dp"
        android:layout_marginEnd="58dp"
        android:layout_marginRight="58dp"
        android:text="hiii"
        android:textSize="35dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>

Пример.Ява

public class Example_ extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_example_);

        LayoutInflater myinflater=getLayoutInflater();
        LinearLayout ln=findViewById(R.id.linear);
View v =myinflater.inflate(R.layout.test1,ln,true);


    }
}
...