NikhithaTarala / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

BarChart unable to display in CustomedListView #128

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add LinearLayout as a chart place holder in customed list row xml file
2. Add LinearLayout
 chartPlaceHolder = (LinearLayout) v.findViewById(R.id.chart);
 chartPlaceHolder.addView(new ServiceBarChart().getView(v.getContext(), "2011", sItem.getServiceStatistics(), "Monthly sales in the last 2 years"),                             new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

What is the expected output? What do you see instead?
I expect the chart to show... I see other text views below the linearlayout show

Please provide a source code snippet that we can use to replicate the issue.
The xml is defined as
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="6dip">
    <LinearLayout
        android:id="@+id/chart"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />
    <!--ImageView
        android:id="@+id/service_statistics"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="6dip"
        android:src="@drawable/icon"
        /-->
    <TextView
        android:id="@+id/service_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:layout_weight="3"
        android:textSize="20dp"
        />
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        >
        <TextView
            android:id="@+id/service_timeleft"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:singleLine="true"
            android:textSize="10dp"
        />
        <TextView
            android:id="@+id/service_status"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="right"
            android:singleLine="true"
            android:textSize="10dp"

        />
    </LinearLayout>
</LinearLayout>

And the customed List Adapter is defined as:
public ServiceItemAdapter(Context context, int textViewResourceId,
                ArrayList<ServiceItem> objects) {
            super(context, textViewResourceId, objects);
            // TODO Auto-generated constructor stub
            this.items = objects;           
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent){
            View v = convertView;
            if(v == null){
                LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.home_item, null);
            }

            ServiceItem sItem = items.get(position);
            if (sItem!= null){
                TextView name = (TextView) v.findViewById(R.id.service_name);
                TextView status = (TextView) v.findViewById(R.id.service_status);
                TextView timeleft = (TextView) v.findViewById(R.id.service_timeleft);
                LinearLayout chartPlaceHolder = (LinearLayout) v.findViewById(R.id.chart);
                if(name!= null){
                    name.setText("Name: " + sItem.getServiceName());
                    status.setText("Status: " + sItem.getServiceStatus());
                    timeleft.setText("TimeLeft: " + sItem.getTimeLeft());
//                  TextView a = new TextView(v.getContext());
//                  a.setText("HI,can u see me?");

                    if( sItem.getServiceStatus() == "On")
                    {
                        chartPlaceHolder.addView(
                                new ServiceBarChart().getView(v.getContext(), "2011", sItem.getServiceStatistics(), "Monthly sales in the last 2 years"),
//                              a,
                                new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
                    }
                }
            }           
            return v;           
        }
    };
}

the other classes related is attached.

What version of the product binary library are you using?
android-2.1

Please provide any additional information below.

Original issue reported on code.google.com by WJingjin...@gmail.com on 4 Sep 2011 at 2:09

Attachments:

GoogleCodeExporter commented 9 years ago
The demo applications shows how to integrate charts inside layouts.

Original comment by dandrome...@gmail.com on 5 Jan 2012 at 4:03