I am very new to Android programming, but I’ve taken a fair amount of tutorials. But still, I am having problems with the following.
I took this tutorial: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html. Besides, I took this tutorial for button clicks: developer.android.com/guide/topics/ui/ui-events.html
I have added a button and an EditText to the first tab layout. Just for testing purposes, I would like the EditText to become invisible if I press the button. Here is my code:
package test.HelloTabWidget;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class ArtistsActivity extends Activity
{
EditText et;
private OnClickListener mCorkyListener = new OnClickListener()
{
public void onClick(View v) {
et.setVisibility(View.INVISIBLE);
}
};
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.artists);
et = (EditText)this.findViewById(R.id.EditText01);
Button button = (Button)this.findViewById(R.id.Button01);
button.setOnClickListener(mCorkyListener);
}
}
This code is for the first tab. I have actually tried to create a new project and just use standard layout, and then use the code above. Then it works perfectly. So I don’t really understand why it won’t work here.
Update: Works now, but I’m afraid that I have no idea what caused the error and why it is now working.
Closing. As stated in the bottom of the original post, the problem fixed itself mysteriously.