Remove All Ads from XDA

Cannot get a simple Hello World app to compile

65 posts
Thanks Meter: 2
By dorlow, Member on 13th February 2020, 05:08 AM
Post Reply Email Thread
Ok, so I'm a very newbe programmer. I do know a little C++. But I wanted to see if I could create a basic Hello World android app. I found a video on YouTube that I'm trying to follow along. I'm pretty sure my code is identical to his code. But mine won't compile.

Here's the code...

package com.example.simplehelloworldapplication;

import android.widget.TextView;

import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {
private TextView textView;
private Button button;

protected void onCreate(Bundle savedInstanceState) {


button.setOnClickListener(new View.OnClickListener() {
boolean visible;

public void onClick(View v) {
visible = !visible;

button.setVisibility(visible? View.VISIBLE:View.VISIBLE);



When I attempt to compile the code, I get 3 errors...

error: incompatible types: no unique maximal instance exists for type variable T with upper bounds Button,View
(It's refering to this error: button=findViewById(

error: cannot find symbol method setVisibility(int)

error: cannot find symbol method setOnClickListener(<anonymous OnClickListener>)

Any suggestions to fix these errors would be greatly appreciated.
14th February 2020, 03:03 PM |#2  
OP Member
Thanks Meter: 2
Ok, so I figured it out. Not from the code above, but I found training on androids website that showed me how to do it and it worked. I now have an app on my phone I created that asks for input and then sends it (to nowhere)
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes