mercredi 25 février 2015

ScrollView onclick set the visibility to be Visible



I have got this Scroll View in my android app and what I am trying to do is set its visibility to be gone. When you click on this button with an id clickme it should change the visibility of the scroll view and set it to be Visible. However when I trying to do this I am getting the error sayign "Unfortunately, ExampleApp has stopped". Basically crashes. this is my code for the button;



<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lastmonth"

android:id="@+id/lastmonth"
android:layout_marginLeft="40dp"
android:paddingLeft="40dp"
android:textSize="14sp" />

<Button


this is the code for the scroll view



<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollview"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="5dp">

<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scrollvisibility">

<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/exampletext"
android:id="@+id/textView10"
android:textColor="#ff010101"
android:textSize="14sp" />

</LinearLayout>

</LinearLayout>
</ScrollView>


this is the code that I have got in my activity;



final View v = null;

v.findViewById(R.id.scrollvisibility).setVisibility(View.GONE);


v.findViewById(R.id.lastMonthButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i("Testing","Button Clicked");
//v.findViewById(R.id.scrollvisibility).setVisibility(View.VISIBLE);
}
});



Aucun commentaire:

Enregistrer un commentaire