Android 如何获取LinearLayout的id

Android 如何获取LinearLayout的id,android,android-linearlayout,Android,Android Linearlayout,这是我的主要活动,很抱歉给你添麻烦 public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; // Perform this loop procedure for each App Widget that belongs to this

这是我的主要活动,很抱歉给你添麻烦

      public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        final int N = appWidgetIds.length;

        // Perform this loop procedure for each App Widget that belongs to this
        // provider
        for (int i = 0; i < N; i++) {
            int appWidgetId = appWidgetIds[i];

            // Get the layout for the App Widget and attach an on-click listener 
            // to the button 
            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.activity_main_widget);

            //Linear layout 
            LinearLayout layout = (LinearLayout)findViewById(R.id.layout1);


            // Create an Intent to launch AppoinTextActivityClass from frontend 
            Intent intent = new Intent(context, AppoinTextActivity.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
            views.setOnClickPendingIntent(R.id.buttonAT, pendingIntent);

            // Create an Intent to launch Day from frontend
            Intent intent1 = new Intent(context, RemindersToday.class);
            PendingIntent pending = PendingIntent.getActivity(context, 0, intent1, 0);
            views.setOnClickPendingIntent(R.id.button2, pending); 

            // Create an Intent to launch Hours from frontend 
            Intent intent2 = new Intent(context, RemindersHour.class);
            PendingIntent pending1 = PendingIntent.getActivity(context, 0, intent2, 0);
            views.setOnClickPendingIntent(R.id.button1, pending1); 

            // Create an Intent to launch Customize from frontend
            Intent intent3 = new Intent(context, ReminderPeriodPicker.class);
            PendingIntent pending2 = PendingIntent.getActivity(context, 0, intent3, 0);
            views.setOnClickPendingIntent(R.id.button3, pending2); 

            appWidgetManager.updateAppWidget(appWidgetId, views);
        } 
      } 
    }
public void onUpdate(上下文上下文,AppWidgetManager AppWidgetManager,int[]appWidgetIds){
final int N=appWidgetIds.length;
//对属于此应用程序的每个应用程序小部件执行此循环过程
//提供者
对于(int i=0;i

有人能帮助我如何获取线性布局的id以及如何从线性布局调用活动吗。谢谢

我不知道你说的“从线性布局调用活动”是什么意思,但是为了获得线性布局的id,在你的onCreate中,膨胀你用作应用程序基本布局的xml。差不多

view = inflater.inflate(R.layout.your_custom_layout);
//be sure that you have defined View view as a global or inside your onCreate.
然后调用线性布局,如

LinearLayout ln = (LinearLayout) view.findViewById(R.id.your_linear_layout)
您需要view.findViewById才能引用LinearLayout所在的父视图

LinearLayout l1=(LinearLayout)视图。findViewById(R.id.your_linear_布局)

您所说的“从LinearLayout调用活动”是什么意思?