English 中文(简体)
斜体 植被内的观察价值
原标题:Android get textView value inside widget

是否有办法从案文中获取价值 植被内的观点? 我在我的植被布局和我的植被更新方面有两点文字,我想给其中一人带来新的价值,我不想改变第二点的价值。 现在,我把这种价值确定为这样的价值。

   remoteViews.setTextViewText(R.id.text1, newValue");
   widgetManager.updateAppWidget(thisWidget, remoteViews);

this is setting value of the second textView to default value defined in layout. How to get it to not change the value of the second textView, or how to get value to the second textView to be able to adjust to the same ?

最佳回答

我的理解是,每当打电话到onUpdate时,它就更新了所有植被,因此我使用的是共享优惠,因此,当我设定了<条码>TextView时,首先,我只读了文本,供大家分享。 我在<条码>范围内这样做。

我的<代码>上:

@Override
public void onUpdate(Context context, AppWidgetManager awm, int[] appWidgetIds){
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    int appWidgetId;
    for (int i=0;i<appWidgetIds.length;i++){
            appWidgetId = appWidgetIds[i];

            String widgetLabel = pref.getString("label"+appWidgetId, "");
            // I previously saved "widgetLabel" when I created the widget in my 
            // ConfigurationActivity
            M.updateWidget(context, appWidgetId, widgetLabel);
                // I put this in another class so it s more manageable.
        }



}

在我的M级:

public static void updateWidget(Context context, int appWidgetId, String widgetLabel){

        SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();

        RemoteViews updateViews;
        int layoutId = R.layout.layout;
        int viewId = R.id.layout;

        updateViews = new RemoteViews(context.getPackageName(),
                layoutId);
        updateViews.setTextViewText(R.id.widgetlabel, widgetLabel);
        editor.putString("label"+appWidgetId, widgetLabel);
        editor.commit();

        Intent intent = new Intent(context, ClickAction.class); 
        PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        updateViews.setOnClickPendingIntent(viewId, pendingIntent);

        AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, updateViews);
    }

我希望这一点是有意义的。 让我知道,我是否需要详细阐述任何问题。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签