How from ExpandableListView on clicking a list item to go to WebView? There is such code: (ExpandableListView)

public class activity_stigmata_detail extends AppCompatActivity { private String[] mGroupsArray = new String[] { ".....", "....", }; private String[] mWinterMonthsArray = new String[] { "..","..."", }; private String[] mSpringMonthsArray = new String[] { "..","...",}; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("Stigmata"); Map<String, String> map; ArrayList<Map<String, String>> groupDataList = new ArrayList<>(); for (String group : mGroupsArray) { map = new HashMap<>(); map.put("groupName", group); groupDataList.add(map); } String groupFrom[] = new String[] { "groupName" }; int groupTo[] = new int[] { android.R.id.text1 }; ArrayList<ArrayList<Map<String, String>>> сhildDataList = new ArrayList<>(); ArrayList<Map<String, String>> сhildDataItemList = new ArrayList<>(); for (String month : mWinterMonthsArray) { map = new HashMap<>(); map.put("monthName", month); сhildDataItemList.add(map); } сhildDataList.add(сhildDataItemList); сhildDataItemList = new ArrayList<>(); for (String month : mSpringMonthsArray) { map = new HashMap<>(); map.put("monthName", month); сhildDataItemList.add(map); } сhildDataList.add(сhildDataItemList); String childFrom[] = new String[] { "monthName" }; int childTo[] = new int[] { android.R.id.text1 }; SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter( this, groupDataList, android.R.layout.simple_expandable_list_item_1, groupFrom, groupTo, сhildDataList, android.R.layout.simple_list_item_1, childFrom, childTo); ExpandableListView expandableListView = (ExpandableListView) findViewById(R.id.expListView); expandableListView.setAdapter(adapter); } 

}

In ListView, you could do this:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_stigmata_detail_4); ListView listView = findViewById(R.id.listView); listView.setAdapter( new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, titles)); listView.setTextFilterEnabled(true); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> a, View v, int position, long id) { Intent intent = new Intent(); intent.setClass(activity_stigmata_detail_4.this, activity_stigmata_detail_4_view.class); intent.putExtra("title", position); startActivity(intent); } }); 

Code from webview

 public class activity_stigmata_detail_4_view extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_stigmata_detail_4_view); WebView webView = findViewById(R.id.webView); Intent intent = getIntent(); String resName = "q" + intent.getIntExtra("title", 0); Log.i("name", resName); Context context = getBaseContext(); String text = readRawTextFile(context, getResources().getIdentifier(resName, "raw")); webView.loadDataWithBaseURL(null, text, "text/html", "UTF-8", null); } private String readRawTextFile(Context context, int resId) { InputStream inputStream = context.getResources().openRawResource(resId); InputStreamReader inputReader = new InputStreamReader(inputStream); BufferedReader buffReader = new BufferedReader(inputReader); String line; StringBuilder builder = new StringBuilder(); try { while (( line = buffReader.readLine()) != null) { builder.append(line); builder.append("\n"); } } catch (IOException e) { return null; } return builder.toString(); } 

}

I tried to find the answer to my question on the Internet, but I did not find the necessary one.

    0