0

ダイアログ内の画像に画像を遅延ロードしようとしています。

私の問題は、ダイアログの外でダイアログからビューを取得して画像を更新できないことです。

各ビューに一意の ID を指定してから、その ID でビューを見つけようとしましたが、null ポインター例外が発生しました。

ここに私のダイアログコードがあります:

public void showAllComents() {

        builderComment = new AlertDialog.Builder(this);

        builderComment.setTitle(dietsList[poisition][0] + " comments");

        View prefView = View.inflate(this, R.layout.show_comments, null);

        builderComment.setCancelable(false);

        editComment = (EditText) prefView.findViewById(R.id.editComment);

        LinearLayout commentsLinear = (LinearLayout) prefView.findViewById(R.id.commentsLinear);

        if (haveComments) {

            int length = comments.length;

            for (int i = 0; i < length; i++)
            {           
                LinearLayout tempLinear = new LinearLayout(this);

                LayoutParams p1 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

                if (i != 0)
                p1.setMargins(0, 20, 0, 0);

                tempLinear.setOrientation(LinearLayout.HORIZONTAL);
                tempLinear.setLayoutParams(p1);

                ImageView image = new ImageView(this);
                p1 = new LayoutParams(64, 64);
                image.setLayoutParams(p1);
                image.setId(6000+i);
                image.setImageDrawable(getResources().getDrawable(R.drawable.anonymous));

                tempLinear.addView(image);

                commentsLinear.addView(tempLinear);
            }

...
...
... \\\Rest of dialog code...

画像をロードしてから、画像ビューを更新しようとします。

public void setCommentedUsersProfilePictrue()
        {
            int lengthUnique = commentsuniqueNames.length;
            int loadLength = comments.length;

            View prefView = View.inflate(this, R.layout.show_comments, null);

            for(int i = 0; i < loadLength; i++)
            {
                for(int j = 0; j < lengthUnique; j++)
                {
                    if(comments[i][1].equals(commentsuniqueNames[j]))
                    {
                        Log.i("user name comment", comments[i][1]);
                        //Log.i("user name", userProfilePictures[i][1]);

                        ImageView tempImage = new ImageView(DietWall.this);

                        tempImage = (ImageView) prefView.findViewById(6000 + i);

                        if(tempImage != null && commentsLoadedPictrues[j][1] != null && commentsLoadedPictrues[j][1].equals("null") == false && commentsLoadedPictrues[j][1].equals("NULL") == false)
                            tempImage.setImageDrawable(new BitmapDrawable(getResources(),decodeBase64(commentsLoadedPictrues[j][1])));
                        else
                            Log.i("null", "null");
                    }
                  } 
                }
              }
4

1 に答える 1