1

GridView画像とテキストを含むカスタムポップアップウィンドウを表示したいという問題があります。画像は Web サービスから取得されていますが、アダプタがGridViewアイテムを表示できません。どうしてか分かりません?同じことに関する解決策を教えてください。

コード:

private void showSearchPopUp()
    {
        View view = LayoutInflater.from(VideoActivity.this).inflate(R.layout.search_pop_up, null);
        PopupWindow popupWindow = new PopupWindow(
                   view, 
                   LayoutParams.WRAP_CONTENT,  
                         LayoutParams.WRAP_CONTENT);  
        popupWindow.setWidth(1230);
        popupWindow.setHeight(800);
        //popupWindow.showAtLocation(imgSearch, Gravity.LEFT|Gravity.TOP, 0, -30);
        popupWindow.showAsDropDown(relHeader, 0, -30);  

        LinearLayout llSearchAlpha = (LinearLayout)view.findViewById(R.id.llSearchAlpha);
        TextView tvAlpha;
        for(int i=0;i<alpha.length;i++)
        {
            tvAlpha = new TextView(VideoActivity.this);
            tvAlpha.setTextColor(Color.WHITE);
            tvAlpha.setText(alpha[i]);
            tvAlpha.setTextSize(15);
            tvAlpha.setLayoutParams(new LinearLayout.LayoutParams(
                        LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT, 1f));
            llSearchAlpha.addView(tvAlpha);
        }
        getActors();
    }

private void getActors()
    {
        View view = LayoutInflater.from(VideoActivity.this).inflate(R.layout.search_pop_up, null);
        final GridView grid = (GridView)view.findViewById(R.id.gvSearch);
        grid.setWillNotDraw(false);
        grid.setFocusableInTouchMode(true);
        grid.setClickable(true);
        new Thread(new Runnable() {

            @Override
            public void run() {
                actors = Server.getSearchActor();
                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        SearchActorCategoryLazyAdapter searchAdapter = new SearchActorCategoryLazyAdapter(VideoActivity.this, actors);
                        grid.setAdapter(searchAdapter);
                    }
                });
            }
        }).start();
    }

public class SearchActorCategoryLazyAdapter extends BaseAdapter 
{
    Context _contextObj;
    List<Actor>  listActor;
    private LayoutInflater inflater;
    private ImageLoader imageLoader;
    public SearchActorCategoryLazyAdapter(Context context, List<Actor> listActor)
    {
        _contextObj = context;
        this.listActor = listActor;
        this.inflater = (LayoutInflater) _contextObj.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.imageLoader = new ImageLoader(_contextObj.getApplicationContext());
    }
    @Override
    public int getCount() 
    {
        return listActor.size();
    }
    @Override
    public Object getItem(int position) 
    {
        return null;
    }
    @Override
    public long getItemId(int position) 
    {
        return 0;
    }

    static class ViewHolder 
    {
        TextView tvActorName;
        ImageView imgSearch;
        int position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolderObj = new ViewHolder();

        LayoutInflater inflaterObj = (LayoutInflater)_contextObj.getSystemService(Service.LAYOUT_INFLATER_SERVICE);


             if (convertView == null) {
                 convertView = (View)inflaterObj.inflate(R.layout.search_griditem, parent,true);
                }
            viewHolderObj.tvActorName = (TextView)convertView.findViewById(R.id.tvSearchName);
            viewHolderObj.imgSearch = (ImageView)convertView.findViewById(R.id.imgSearch);

            viewHolderObj.tvActorName.setText(listActor.get(position).getActor_name());
            Activity activity = (Activity)_contextObj;
            imageLoader.displayImage(listActor.get(position).getActor_image(), activity, viewHolderObj.imgSearch);


        return convertView;
    }
}

前もって感謝します。

4

1 に答える 1