Java Android ExpandableListView中每行两个文本视图

Java Android ExpandableListView中每行两个文本视图,java,android,expandablelistview,Java,Android,Expandablelistview,我的应用程序中有一个可扩展的文本视图。我可以让它在一个文本视图中显示所有信息,但我真的希望其中一行文本以粗体突出,因此我认为最好的方法是使用第二个文本视图,然后在其中设置它。我看了很多例子,但我不太明白如何把它放进去。 主要活动- ExpandableListAdapter listAdapter; ExpandableListView experienceExpList; List<String> experienceHeaders; HashMap<String, List

我的应用程序中有一个可扩展的文本视图。我可以让它在一个文本视图中显示所有信息,但我真的希望其中一行文本以粗体突出,因此我认为最好的方法是使用第二个文本视图,然后在其中设置它。我看了很多例子,但我不太明白如何把它放进去。 主要活动-

ExpandableListAdapter listAdapter;
ExpandableListView experienceExpList;
List<String> experienceHeaders;
HashMap<String, List<String>> experienceChild;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_xtra_adventures);

    experienceExpList = (ExpandableListView) findViewById(R.id.lvExp); //call list view
    prepareListData(); //get the list data function

    listAdapter = new ExpandableListAdapter(this, experienceHeaders, experienceChild); //creates list adapter
    experienceExpList.setAdapter(listAdapter); //set list adapter

    //eventually onclick listener to purchase experience
}

private void prepareListData() {
    experienceHeaders = new ArrayList<String>();
    experienceChild = new HashMap<String, List<String>>();

    // Adding child data
    experienceHeaders.add("Experiences");
    List<String> experiences = new ArrayList<String>();

    try {

        JSONArray mainNode = new JSONArray(loadJSONFromAsset()); // call the connection to json


        if(mainNode != null) //puts the values into an array
        {
            for(int i=0;i<mainNode.length();i++)
            {
                JSONObject eachObject = mainNode.getJSONObject(i);

                String type = eachObject.getString("type");

                if(type.equals("Experience"))
                {
                    String name = eachObject.getString("name");
                    String price = eachObject.getString("price");
                    String description = eachObject.getString("description");

                    String experience = (name + "\n" + price + "\n" + description);

                    experiences.add(experience);
                }
            }
        }
    }
    catch (JSONException e)
    {
        e.printStackTrace();
    }

    experienceChild.put(experienceHeaders.get(0), experiences); // Header, Child data
}
在我的列表项(子)xml布局中,我有一个文本视图lvlListItem,但我真正想做的是设置第二个,它只显示名称
String name=eachObject.getString(“name”)进入MainActivity.java

任何关于如何设置第二个文本视图的帮助都将不胜感激,因为我似乎不知道如何将它与我所拥有的连接起来

列表项xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="55dip"
android:orientation="vertical" >

<TextView
    android:id="@+id/lblListItem"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="17dip"
    android:paddingTop="5dp"
    android:paddingBottom="5dp"
    android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" />

<TextView
    android:id="@+id/lblListItem2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="17dip"
    android:paddingTop="5dp"
    android:paddingBottom="5dp"
    android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" />


将另一个文本视图添加到布局文件
exp\u list\u项中

在主活动中,您已经向适配器添加了所需的字符串。因此,在适配器中,拆分字符串并将名称分配给一个textView,将字符串的其余部分分配给另一个

String[] data = childText.split("\n");

String name = data[0];
String restOfInfo = data[1] + "\n" + data[2];

将另一个
TextView
添加到
exp\u list\u item.xml
。是的,我知道,我只是不知道如何将它连接到其余部分,并为其分配一个我想要的值。你没有解释清楚,因为你没有展示你想要的尝试。很难准确地理解您是在第二个文本视图的布局中添加到哪里并添加到ChildView中的,或者仅仅使用
txtListChild.setText(HTML.fromHtml(childText+“”+price+“”))其中price是数字或text是要加粗的文本。
String[] data = childText.split("\n");

String name = data[0];
String restOfInfo = data[1] + "\n" + data[2];