Reputation: 1318
I have an activity (MainActivity.java
) in which content view is like this
this.setContentView(R.layout.standalone_example);
my standalone_example.xml is like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.abc.view.PageCurlView
android:id="@+id/dcgpagecurlPageCurlView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/page1" />
</RelativeLayout>
I am done some work in PageCurlView.java
now I want to access objects and variables of PageCurlView.java
in my MainActivity.java
, I am searching for hours but couldnt find any answer, any suggestions thanks in advance.
Upvotes: 0
Views: 2725
Reputation: 4178
You can get a reference to the inflated PageCurlView using findViewById() in your activity. In a method in your activity:
PageCurlView mPageCurlView = (PageCurlView) findViewById(R.id.dcgpagecurlPageCurlView1);
You can then call methods or access public variables on mPageCurlView. Please note that setContentView() must be called first in your activity before you can use findViewById().
Upvotes: 1