Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将带有动态文本视图的LinearLayout添加到小部件的RemoteView_Android_Android Layout_Android Linearlayout_Appwidgetprovider_Android Remoteview - Fatal编程技术网

Android 将带有动态文本视图的LinearLayout添加到小部件的RemoteView

Android 将带有动态文本视图的LinearLayout添加到小部件的RemoteView,android,android-layout,android-linearlayout,appwidgetprovider,android-remoteview,Android,Android Layout,Android Linearlayout,Appwidgetprovider,Android Remoteview,我已经尝试过向RemoteView添加带有一些动态文本视图(运行时)的linearlayout(xml定义) 我在xml布局中定义了linearlayout,如下所示: calendarlayout.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout

我已经尝试过向RemoteView添加带有一些动态文本视图(运行时)的linearlayout(xml定义)

我在xml布局中定义了linearlayout,如下所示:

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>

并尝试在我的remoteview中与一些动态文本视图一起使用它

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);          
}
RemoteViews-RemoteViews=新的远程视图(上下文)
.getApplicationContext().getPackageName(),R.layout.calendarlayout);

对于(int i=0;i首先需要将所有动态文本视图添加到线性布局,然后再将线性布局添加到remotview@GangaNaidu感谢您的建议,但不幸的是AppWidgetManager正在通过其Remoteview完成所有xml资源工作。我还无法通过Remoteview初始化预定义的linearlayout。。