0

私はアンドロイドでカスタマイズされたリストビューを使用しています.私のカスタマイズされたリストビュークラスVoucherlistcustomization1には、linearlayoutearnloyaltypoints1という名前のlinearlayoutがあります。外側のクラスバウチャーのレイアウトバウチャーの別のレイアウトのオンクリックで、レイアウトをlinearlayoutearnloyaltypoints1のvisibiltyにする必要があります。外部クラスのレイアウトへのアクセス。

    public class Voucher extends Activity implements OnClickListener,OnItemClickListener
    {

        ListView listviewvoucher;
        private Voucherlistcustomization1 vouchertextadapter=null;
        public ArrayList<String>Addelemntstovoucher = new ArrayList<String>();

        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.voucher);

            Addelemntstovoucher.add("SHOPPER STOP");
            Addelemntstovoucher.add("Expire date:5-8-2012");

            if(vouchertextadapter == null)
            {
                vouchertextadapter=new Voucherlistcustomization1(this,0, Addelemntstovoucher);

            }   

            listviewvoucher.setAdapter(vouchertextadapter);


            Log.d("customerfaname",""+Addelemntstovoucher);


            listviewvoucher.setOnItemClickListener(new OnItemClickListener() 
            {

                @Override
                public void onItemClick(AdapterView<?> a, View v, int position,long id) 
                {
                    Log.d("Clicked","bbbbbbbbbbbbbbbbbb"+a);

                }
            }); 
        }   

        @Override
        public void onClick(View v) 
        {
        if(v==linearlayout_Voucher_to_Grab){
                linearlayoutearnloyaltypoints1.setVisibility(View.GONE) ;
        }

        }

        public class Voucherlistcustomization1 extends ArrayAdapter<String>
        {
            LinearLayout linearlayoutearnloyaltypoints1;

            public Voucherlistcustomization1(Context context, int textViewResourceId,List<String> objects) 
            {

                super(context, textViewResourceId,objects);

            }


            public View getView(int position, View convertView, ViewGroup parent) 
            {
                if(convertView == null) 
                {
                    convertView = LayoutInflater.from(getContext()).inflate(R.layout.customized_listview_for_voucher, null);                
                }


                linearlayoutearnloyaltypoints1=(LinearLayout)findViewById(R.id.linearlayoutearnloyaltypoints1);

                          //components present in the  customized_listview_for_voucher layout
                String text1 = getItem(position);
                TextView textView1 = (TextView) convertView.findViewById(R.id.textview1);
                textView1.setText(text1);

                String text2 = getItem(position);
                TextView textView2 = (TextView) convertView.findViewById(R.id.textView2);
                textView2.setText(text2);

                String text3 = getItem(position);
                TextView textView3 = (TextView) convertView.findViewById(R.id.textView3);
                textView3.setText(text3);


                return convertView;
            }    

        }

    }

My issue here is that on the Onclick of :
    (v==linearlayout_Voucher_to_Grab)   
    {
            linearlayoutearnloyaltypoints1.setVisibility(View.GONE) ;
    }



I am trying to make the layout  linearlayoutearnloyaltypoints1.setVisibility(View.GONE) ; visibity to gone however the layout(linearlayoutearnloyaltypoints1) is a component in the class Voucherlistcustomization1 in the Inner class Voucherlistcustomization1.Can someone please tell me how do i set the visibity of that layout to false.
4

1 に答える 1

0

試してみてください:

runOnUIThread(new Runnable {
   public void run() {
      layout.setVisibility(View.GONE);
   }
})

問題は、元のスレッドにないビューで作業している可能性があり、それが解決策になります

于 2012-10-03T09:10:52.437 に答える