0
My point is, simple fact is I don’t know much about this yet.
I’m having a problem with invisibility, I have a vertical Linearlayout with two buttons and when I click on the first appears another Linearlayout that I set and the second button goes down (all right so far)but when I click the first button again for the textviews to disappear the second button does not return to the starting position, which I have to use to make it possible?
XML
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linearLayout">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button" />
<LinearLayout
android:visibility="gone"
android:id="@+id/lol"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOLOLOLLOLOL"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOLOLOLLOLOL"/>
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOLatuabelha"
android:id="@+id/belha"
android:layout_below="@+id/linearLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
JAVA
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button botao;
botao = (Button) findViewById(R.id.button);
final LinearLayout lol = (LinearLayout) findViewById(R.id.lol);
botao.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (lol.getVisibility() == View.VISIBLE){
lol.setVisibility(View.INVISIBLE);
}
else{
lol.setVisibility(View.VISIBLE);
}
}
}
);
}
}
That’s right, thank you very much for your help!
– Pedro Miguel