1

I have tried so much to add a linearlayout(xml defined) with some dynamic textviews(runtime) to RemoteView.

I defined the linearlayout in my xml layout like:

calendarlayout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutClickable"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/myshape"
android:padding="4dp" >

<LinearLayout
    android:id="@+id/layoutParentView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="70dp"
    android:orientation="vertical"
    android:padding="4dp" >

</LinearLayout>

And tried to use it in my remoteview with some dynamic textviews.

RemoteViews remoteViews = new RemoteViews(context
            .getApplicationContext().getPackageName(), R.layout.calendarlayout);
for(int i=0; i<event_row_counter; i++ ){
CalendarEvent mCalendarEvent = new CalendarEvent();
mCalendarEvent = CALENDAR_EVENTS.get(i);    
TextView mTextView = new TextView(context);
mTextView.setId(i);

RemoteViews textRemoteView = new 
RemoteViews(context.getApplicationContext().getPackageName(), R.layout.calendarlayout);
remoteViews.setTextViewText(mTextView.getId(), mCalendarEvent.getFormatedTime()+" "+mCalendarEvent.getTitle());
remoteViews.addView(R.layout.calendarlayout, textRemoteView);          
}

I know my process is fully wrong, but I unable to found any way to add the linearlayout with dynamic textviews into the remoteview yet.

Suggestions are mostly appreciated.

Ranjit
  • 5,130
  • 3
  • 30
  • 66
  • First u need to add all dynamic textview to the linear layout, and then next add linear layout to the remotview – GangaNaidu Apr 28 '14 at 11:49
  • @GangaNaidu Thanks for a suggestion, but unfortunately AppWidgetManager is doing all its xml resource stuff through its Remoteview..and am unable to initialize my predefined linearlayout through remoteview yet.. – Ranjit Apr 28 '14 at 11:55

0 Answers0