0

I have this problem with a Button. It won't open a URL when you click on it. Don't know what's the problem. I would appreciated if somebody would help. Thanks.

public class Tours implements Serializable  {

 private String mId;
 private String mTitle;
 private String mYear;
 private String mCoord;

public Tours(){}

public Tours(String id, String title, String year, String coord) {
    this.mId = id;
    this.mTitle = title;
    this.mYear = year;
    this.mCoord = coord;
}

public String getId() {return mId;}

public void setId(String id) {this.mId = id;}

public String getTitle() {return mTitle;}

public void setTitle(String title) {this.mTitle = title;}

public String getYear() {return mYear;}

public void setYear(String year) {this.mYear = year;}

public String getCoord() {return mCoord;}

public void  setCoord(String coord) {this.mCoord = coord;}

}

3 Answers3

0

Add a web View

Webview webView=(WebView)findViewById(R.id.webView1);

And Write This code where you want a do the task

String url="Your Url";
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    startActivity(browserIntent);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
Reality
  • 17
  • 8
0

Inside your oncreateVew() butterknife initialize place add

 @Nullable
 @Override
 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup 
 container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.about_fragment, container, 
        false);
        ButterKnife.bind(getActivity(), view);
        return view;

}

@OnClick(R.id.bAbout)
public void someButtonOnClick(View view) {
 String url = "http://www.example.com";
 Intent i = new Intent(Intent.ACTION_VIEW);
 i.setData(Uri.parse(url));
 startActivity(i);
}
Ramesh sambu
  • 3,577
  • 2
  • 24
  • 39
  • I'm getting a bunch of errors when I enter getActivity() as cotext, same for this. –  Dec 19 '17 at 19:04
  • I did. But there is much more errors, it's too long,It's like whole app is wrong, and I know it's not the case.I mean, I have other fragment that contains list of members of the band, also with Intent, and works perfectly.I used "this" for context. –  Dec 19 '17 at 23:03
0

You are getting a NullPointerException at some point of your code. Probably at this line: Tours.java:84 But that code is not in yuor post..

Read: What is a NullPointerException, and how do I fix it?

adalpari
  • 3,052
  • 20
  • 39
  • I know that.But when I click on Tours.84, it shows me a class in which there is no line 84, and that makes no sense to me.I'll put the class into my code, so that you can see for yourself. –  Dec 20 '17 at 14:43
  • Your logcat said Tours.onDataChange(), where is that method? – adalpari Dec 21 '17 at 13:52
  • You are changing the question all the time, accepting answer without being resolved.. This is not the way StackOverflow works – adalpari Dec 21 '17 at 13:53