akky777
akky777

Reputation: 423

textview click event in dialogbox

I want text click event in a dialogbox. but when I click on image it shouts down... when I should click on the link it should move to the browser and open that link... please help...

this is my code:

ivworkshivalik.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            final Dialog dialog = new Dialog(Ourwork.this);
            dialog.setContentView(R.layout.shivalik);
            dialog.setTitle("SHIVALIK PROJECTS");


            TextView tvshivalik1 = (TextView) dialog.findViewById(R.id.tvshivalik1);
            TextView tvshivalik2 =(TextView)findViewById(R.id.tvshivalik2);
            tvshivalik2.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    // TODO Auto-generated method stub
                    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.shivalikprojects.com/"));
                    startActivity(browserIntent);
                }
            });
            dialog.show();

        }
    });

Upvotes: 0

Views: 873

Answers (3)

Bhavesh Vadalia
Bhavesh Vadalia

Reputation: 814

Insted of this

TextView tvshivalik2 =(TextView)findViewById(R.id.tvshivalik2);

you should try

TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);

Upvotes: 1

M D
M D

Reputation: 47817

You should replace this

 TextView tvshivalik2 =(TextView)findViewById(R.id.tvshivalik2);

With

 TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);

Upvotes: 3

Raghunandan
Raghunandan

Reputation: 133560

You need to initialize as below. The same way you initialized tvshivalik1

 TextView tvshivalik2 =(TextView)dialog.findViewById(R.id.tvshivalik2);

assuming your shivalik.xml has a textview with id tvshivalik2.

Upvotes: 0

Related Questions