1

iam so sorry,my english language is so bad,my question is if button is clicked ,for example [link] (http://example.com:xxx/exp.php) ,the button will send a query for execute php script,without any change in applicationn

but on java activity ,idont know to crete a class onclicklistener im realy new on android dev app

here is my code

 <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ON"
    android:id="@+id/button"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="OFF"
    android:id="@+id/button2"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/button"
    android:layout_toEndOf="@+id/button" />

<WebView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/webView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_below="@+id/button" />
  • 2
    I am sorry because I do not really understand your question (and for laughing a little while reading your question). Are you trying to say that you would like a webpage to be opened in your Android application after the button is clicked? You do not want the webpage to be displayed in the phone's browser? Can you show the codes for the button's listener too? – karansky Mar 17 '16 at 03:53
  • iam so sorry,my english language is so bad, – Ahmad Yusuf Mar 17 '16 at 06:29
  • Where is onClick prop? – NightFury Mar 17 '16 at 06:41
  • Place a webview in invisible mode or height and width as "0". and on button click load your url to that webview. For onClickListener(...) refer this http://stackoverflow.com/questions/25803727/android-setonclicklistener-method-how-does-it-work – Nitesh Mar 17 '16 at 06:41
  • and please try googling first before asking any beginner level question on SO. – Nitesh Mar 17 '16 at 06:44
  • ok i will try to searc – Ahmad Yusuf Mar 17 '16 at 06:49
  • Possible duplicate of [Button Click Event on Android](http://stackoverflow.com/questions/8781468/button-click-event-on-android) – Viral Patel Mar 17 '16 at 12:06

1 Answers1

1

You need set a ClickListener at your button:

Button button = (Button) findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });
dpulgarin
  • 556
  • 5
  • 17