I came across a post which exaplains that if I add android:onClick="OnClickMethod"
to the <LinearLayout>
in the XML file, and then in the JAVA file I add
public void OnClickMethod(View v) {
Intent intent= new Intent(getApplicationContext(), SecondActivity.class);
startActivityForResult(intent, START_INTENT);
}
It should make the LinearLayout clickable. Which it does. But, I have the following setup in my XML file:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:padding="0dp"
android:id="@+id/linearLayout1"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:padding="5dp"
>
<ImageView
android:id="@+id/imageView1"
android:src="@drawable/myIcon"
android:gravity="center_vertical|center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
/>
<TextView
android:id="@+id/textView1"
android:text="xxx"
android:gravity="center_vertical|center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/myChart"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
If I add android:OnClick="OnClickMethod"
to the linearLayout1
it makes only the TextView
and Image
clickable. But ideally I want the graph to be clickable. I tried adding android:OnClick="OnClickMethod"
to myChart
LinearLayout and it did not make that area clickable at all.
BTW, the myChart
LinearLayout displays AChartEngine dynamic plot. and I disabled the X and Y pans so the user cannot move the graph around (renderer.setPanEnabled(false, false)
Please exaplain to me what I am doing wrong? I want the plot to be clickable. I feel that I am missing something.
Thanks
In order to add click interaction to your chart, you will have to enable the click interaction and add an OnClickListener
on the chart view. You can see this working in this example, lines #156 to #176.