Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create listview with links to assets html file?
    primarykey
    data
    text
    <p>I have an activity which I want to show ListView with list of topics, which linked to html files in assets folder.</p> <p>Here is a code for files from <em>res/raw</em> folder (they named as n0.txt, n1.txt etc.):</p> <pre><code>public class ViewActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.view); Bundle bundle = getIntent().getExtras(); String itemname = "n" + bundle.getString("defStrID"); //getting string and forming resource name Context context = getBaseContext(); //getting context //reading text file from resources by name String text = readRawTextFile(context, getResources().getIdentifier(itemname, "raw", "ru.falcon5f.carguide;")); WebView wWebView = (WebView) findViewById(R.id.webView); String summary = "&lt;!Doctype html&gt;&lt;html&gt;&lt;head&gt;&lt;meta charset=utf-8&gt;&lt;/head&gt;&lt;body&gt;" + text + "&lt;/body&gt;&lt;/html&gt;"; wWebView.loadData(summary, "text/html", "utf-8"); //uploading text to webview } public static String readRawTextFile(Context ctx, int resId) //reading text raw txt file { InputStream inputStream = ctx.getResources().openRawResource(resId); InputStreamReader inputreader = new InputStreamReader(inputStream); BufferedReader buffreader = new BufferedReader(inputreader); String line; StringBuilder text = new StringBuilder(); try { while (( line = buffreader.readLine()) != null) { text.append(line); text.append('\n'); } } catch (IOException e) { return null; } return text.toString(); } } </code></pre> <p>How can I do this for html files from assets (they named n0.html etc)?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload