S
S
sdfg sdfg2016-07-02 10:58:14
Java
sdfg sdfg, 2016-07-02 10:58:14

How can I fix the error in the "hello world" code?

I want that when I click on my button in the application, the text field changes to my custom text. This is probably a simple task, but I need your help!
here is the MainActivity.java script

package com.example.maratmkhitaryan.maratfirsapp;

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

import java.io.Console;

public class MainActivity extends AppCompatActivity {

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

    public void onMyButtonClick()
    {
        TextView textElemetnt = (TextView) findViewById(R.id.textView);
        textElemetnt.setText("Hello programm has stopped")
        System.out.println("Hello world");
    }
}

And here is the xml application map of the application:
<?xml version="1.0" encoding="utf-8"?>
<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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.maratmkhitaryan.maratfirsapp.MainActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Marat Help!"
        android:id="@+id/BuutonHelp"
        android:onClick="onMyButtonClick"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="70dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Large Text"
        android:id="@+id/textView"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:layout_alignParentEnd="false"
        android:layout_alignParentStart="false"
        android:allowUndo="false"
        android:autoText="false" />
</RelativeLayout>

And here is the error that comes out
125483d96ae54227a565185b8f57e310.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2016-07-02
@maratARMENIA

Write logs, screenshot about nothing.
I believe you need to accept an argument in the onMyButtonClick method - View v

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question