마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

위젯에 대해서 질문 있습니다..?

0 추천

<?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="fill_parent">
  <Button
     android:text="Click"
     android:id="@+id/button"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:gravity="center"
     android:layout_gravity="right">
    </Button>
   <TextView
     android:id="@+id/text"
     android:text="test! START!"
     android:layout_width="fill_parent"
      android:background="#00FFFFFF"
      android:textSize="20sp"
      android:layout_height="60dp">
   </TextView>
</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 provider
        for (int i=0; i<N; i++) {
            int appWidgetId = appWidgetIds[i];

            // Create an Intent to launch ExampleActivity
            Intent intent = new Intent(context, ExampleActivity.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
   
            // Get the layout for the App Widget and attach an on-click listener
            // to the button
            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.example_appwidget);
            views.setOnClickPendingIntent(R.id.button, pendingIntent);

            //RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.example_appwidget);
            //위젯 갱신.
   views.setTextViewText(R.id.text, ""+Integer.toString(curCount));
         
            // Tell the AppWidgetManager to perform an update on the current app widget
            appWidgetManager.updateAppWidget(appWidgetId, views);
        }
    }

버튼을 클릭하면 ExampleActivity.class을 실행하는게 아니라  버튼을 클릭할띠마다 더하기1을 해서 TextView에 뿌려주는걸 하고 싶습ㄴ;디
   

헨씀히포 (3,660 포인트) 님이 2014년 5월 6일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...