StackedWidget보기가 표시되지 않음

CQM

내 StackedWidget보기가 텍스트보기 일 때 런처 화면에 표시되었지만 더 복잡한 레이아웃 (A RelativeLayout, imageview, textviews)에서는 아무것도 표시하지 않습니다.

RemoteViews 설정에 대해 알아야 할 것이 있습니까?

widget_item.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_item"
android:layout_width="270dp"
android:layout_height="150dp">

<ImageView
    android:id="@+id/timelineCellImage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:onClick="onClick"
    android:scaleType="centerCrop"
    android:src="@drawable/bottom_grey_gradient"
   />

<LinearLayout
    android:id="@+id/timelineCellTextHolder"
    android:layout_width="match_parent"
    android:layout_height="@dimen/fifty_dp"
    android:layout_alignBottom="@id/timelineCellImage"
    android:layout_alignLeft="@id/timelineCellImage"
    android:background="@drawable/rounded_edges_bottom_dark"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginLeft="@dimen/five_dp"
        android:layout_marginRight="@dimen/five_dp"
        android:layout_marginTop="@dimen/ten_dp"
        android:layout_weight=".5"
        android:ellipsize="end"
        android:gravity="bottom"
        android:lines="1"
        android:text="Test"
        android:textColor="@color/white"
        android:textSize="@dimen/twelve_sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/subheading"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginBottom="@dimen/ten_dp"
        android:layout_marginLeft="@dimen/five_dp"
        android:layout_marginRight="@dimen/five_dp"
        android:layout_weight=".5"
        android:ellipsize="end"
        android:gravity="top"
        android:lines="1"
        android:text="Subtest"
        android:textColor="@color/white"
        android:textSize="@dimen/twelve_sp" />
</LinearLayout>

StackWidgetService.java $getViewAt(int)

public RemoteViews getViewAt(int position) {
    // position will always range from 0 to getCount() - 1.
    RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
    if(!mWidgetItems.isEmpty()){
        // We construct a remote views item based on our widget item xml file, and set the
        // text based on the position.

        rv.setTextViewText(R.id.title, mWidgetItems.get(position).getTitle()); //probably only top stories items, editorial stuff
        rv.setTextViewText(R.id.subheading, mWidgetItems.get(position).getLinkAbstract());
        rv.setImageViewUri(R.id.timelineCellImage, Uri.parse(mWidgetItems.get(position).getCoverImageUrl()));

        // Next, we set a fill-intent which will be used to fill-in the pending intent template
        // which is set on the collection view in StackWidgetProvider.
        Bundle extras = new Bundle();
        extras.putInt(StackWidgetProvider.EXTRA_ITEM, position);
        Intent fillInIntent = new Intent();
        fillInIntent.putExtras(extras);
        rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);

        // You can do heaving lifting in here, synchronously. For example, if you need to
        // process an image, fetch something from the network, etc., it is ok to do it here,
        // synchronously. A loading view will show up in lieu of the actual contents in the
        // interim.
        /*new ImageRequest(
                url,
                listener,
                maxWidth,
                maxHeight,
                decodeConfig,
                errorListener);

        Response.Listener<Bitmap> listener = new Response.Listener<Bitmap>() {
            @Override
            public void onResponse(Bitmap bitmap) {
                // use your bitmap
            }
        };*/

    }
    else
    {
        rv.setTextViewText(R.id.title, "my title"); 
        rv.setTextViewText(R.id.subheading, "");
        rv.setImageViewResource(R.id.timelineCellImage, R.drawable.top_grey_gradient);

        Bundle extras = new Bundle();
        extras.putInt(StackWidgetProvider.EXTRA_ITEM, position);
        Intent fillInIntent = new Intent();
        fillInIntent.putExtras(extras);
        rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);
    }

    try {
        System.out.println("Loading view " + position);
        Thread.sleep(500);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    // Return the remote views object.
    return rv;
}
매니쉬 물리 마니

로컬 이미지를 사용하는 경우 RemoteViews.setImageViewUri.

String url = new File(mWidgetItems.get(position).getCoverImageUrl()).toString();
rv.setImageViewUri(R.id.timelineCellImage, Uri.parse(url));

네트워크 리소스를 사용하는 경우 RemoteViews.setImageViewBitmap.

   Bitmap bm = getImageBitmap(mWidgetItems.get(position).getCoverImageUrl());
   rv.setImageViewBitmap(R.id.timelineCellImage, bm);

   // Helper method to get Image bitmap
   private Bitmap getImageBitmap(String purl) {
        Bitmap bm = null;
        try {
            URL url = new URL(purl);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.connect();
            try {
                InputStream in = new BufferedInputStream( urlConnection.getInputStream() );
                bm = BitmapFactory.decodeStream(in);
            } finally {
                urlConnection.disconnect();
            }
        } catch (MalformedURLException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } 

        return bm;
    }

에서 clickableonClick특성을 제거 합니다 ImageView. onClick속성은 setOnClickListener. 앞서 작성한 답변을 참조 할 수 있습니다 . ImageView원격 뷰의 경우 클릭 이벤트를 처리 하려면 RemoteViews.setOnClickPendingIntent 를 사용해야합니다 .

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Recycler보기가 표시되지 않음

분류에서Dev

활동 표시기보기가 표시되지 않음

분류에서Dev

백본보기가 표시되지 않고 오류가 표시되지 않음

분류에서Dev

RecyclerView가 표시되지 않음 (표시)

분류에서Dev

SwiftUI 미리보기가 표시되지 않음 (오류 없음)

분류에서Dev

정보 표시 자리 표시자가 표시되지 않음

분류에서Dev

팝업 웹보기의 키보드가 표시되지 않음

분류에서Dev

팝업 웹보기의 키보드가 표시되지 않음

분류에서Dev

원형 이미지보기가 표시되지 않음

분류에서Dev

웹보기-웹 페이지가 표시되지 않음

분류에서Dev

여러 이미지 미리보기가 표시되지 않음

분류에서Dev

이미지 src가보기에 표시되지 않음

분류에서Dev

보기에 이미지가 표시되지 않음

분류에서Dev

컬렉션보기에 이미지가 표시되지 않음

분류에서Dev

ViewPager에 사용자 지정보기가 표시되지 않음

분류에서Dev

보기 기반 NSTableView 데이터가 표시되지 않음

분류에서Dev

기본이 아닌보기 필터가 표시되지 않음

분류에서Dev

가시성 : 표시되지 않음

분류에서Dev

$ rootScope가 작동하지 않음-값이보기에 표시되지 않음

분류에서Dev

Google지도가 표시되지 않음

분류에서Dev

android :지도가 표시되지 않음

분류에서Dev

이미지가 표시되지 않음

분류에서Dev

컬렉션보기에 그림자가 표시되지 않음

분류에서Dev

FullCalendar가 Asp.Net Core Razor보기에 표시되지 않음

분류에서Dev

SearchView onQueryTextSubmit에서 만들 때보기가 표시되지 않음

분류에서Dev

헤더가 모바일보기에 표시되지 않음

분류에서Dev

팝 오버보기 컨트롤러가 표시되지 않음

분류에서Dev

백본보기가 표시되지 않음

분류에서Dev

내 부분보기가 표시되지 않음

Related 관련 기사

  1. 1

    Recycler보기가 표시되지 않음

  2. 2

    활동 표시기보기가 표시되지 않음

  3. 3

    백본보기가 표시되지 않고 오류가 표시되지 않음

  4. 4

    RecyclerView가 표시되지 않음 (표시)

  5. 5

    SwiftUI 미리보기가 표시되지 않음 (오류 없음)

  6. 6

    정보 표시 자리 표시자가 표시되지 않음

  7. 7

    팝업 웹보기의 키보드가 표시되지 않음

  8. 8

    팝업 웹보기의 키보드가 표시되지 않음

  9. 9

    원형 이미지보기가 표시되지 않음

  10. 10

    웹보기-웹 페이지가 표시되지 않음

  11. 11

    여러 이미지 미리보기가 표시되지 않음

  12. 12

    이미지 src가보기에 표시되지 않음

  13. 13

    보기에 이미지가 표시되지 않음

  14. 14

    컬렉션보기에 이미지가 표시되지 않음

  15. 15

    ViewPager에 사용자 지정보기가 표시되지 않음

  16. 16

    보기 기반 NSTableView 데이터가 표시되지 않음

  17. 17

    기본이 아닌보기 필터가 표시되지 않음

  18. 18

    가시성 : 표시되지 않음

  19. 19

    $ rootScope가 작동하지 않음-값이보기에 표시되지 않음

  20. 20

    Google지도가 표시되지 않음

  21. 21

    android :지도가 표시되지 않음

  22. 22

    이미지가 표시되지 않음

  23. 23

    컬렉션보기에 그림자가 표시되지 않음

  24. 24

    FullCalendar가 Asp.Net Core Razor보기에 표시되지 않음

  25. 25

    SearchView onQueryTextSubmit에서 만들 때보기가 표시되지 않음

  26. 26

    헤더가 모바일보기에 표시되지 않음

  27. 27

    팝 오버보기 컨트롤러가 표시되지 않음

  28. 28

    백본보기가 표시되지 않음

  29. 29

    내 부분보기가 표시되지 않음

뜨겁다태그

보관