If the URL directly depends on the identifier, try the following:
public void webClick(View v) { Intent intent = new Intent(this, Webview.class); intent.putExtra("weblink","file:///android_asset/chapter/chapter" + v.getId() + ".html"); startActivity(intent); }
edited
If the URL does not depend directly on the identifier, try matching the identifiers of the buttons with the URLS, for example:
Map<Integer, String> urls = new HashMap(); urls.put(R.id.button1, "file:///android_asset/chapter/chapter100.html");
and change the above code as follows:
public void webClick(View v) { Intent intent = new Intent(this, Webview.class); intent.putExtra("weblink", urls.get(v.getId())); startActivity(intent); }
EDITED # 2
If you already have a URL on the shortcut of your buttons, sugestion (not mine, but made by @pad) will use it to calculate the URL like this:
public void webClick(View v) { Intent intent = new Intent(this, Webview.class); intent.putExtra("weblink", "file:///android_asset/chapter/chapter" + v.getText().replaceAll("Chapter ","") + ".html");
source share