I have layout.xml associated with activity1 which have various components including linearlayout, I have also stored one progressbar in progress.xml and on run time using LayoutInflater I am retrieving the progressbar and adding it to linearlayout of layout.xml
My progress.xml :
Case 1 :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ProgressBar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="100dp"
android:layout_height="102dp"
android:layout_gravity="center"
android:indeterminate="false"
android:max="100"
android:progress="100"
android:progressDrawable="@drawable/custom_bar"
/>
</LinearLayout>
Case 2 :
<?xml version="1.0" encoding="utf-8"?>
<ProgressBar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="100dp"
android:layout_height="102dp"
android:layout_gravity="center"
android:indeterminate="false"
android:max="100"
android:progress="100"
android:progressDrawable="@drawable/custom_bar"
/>
When I am using xml in case1 I can successfully add progress bar at run time but when I am using case2 xml I cant add progress bar at run time... please help..
I am using following code to add progressbar from case2 xml :
LinearLayout ll = (LinearLayout) findViewById(R.id.container_linear_layout);
LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View otherView = layoutInflater.inflate(R.layout.progress, null);
pb = (ProgressBar) otherView.findViewById(R.id.progressBar1);
ll.addView(pb);