Теперь при нажатии на пункт ListFragment приложение закрывается с ошибкой, из ListActivity работает.
Вот ViewActivity
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.webkit.WebView;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import ru.aam.pril.R;
public class ViewActivity extends Activity {
private WebView web;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
Bundle bundle = getIntent().getExtras();
String itemname = "n" + bundle.getString("defStrID");
Context context = getBaseContext();
String text = readRawTextFile(context,
getResources().getIdentifier(itemname, "raw", "ru.aam.pril"));
web = (WebView) findViewById(R.id.webview);
web.loadDataWithBaseURL("file:///android_res/raw/",
"<!Doctype html><html><head><meta charset=utf-8></head><body>"
+ text + "</body></html>", "text/html", "utf-8", "");
}
public static String readRawTextFile(Context ctx, int resId)
{
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();
}
}