【问题标题】:show row information in textview Android在 textview Android 中显示行信息
【发布时间】:2014-06-21 06:55:38
【问题描述】:

我的第一个屏幕中有一个 listView,我在 json 的每一行中显示信息,当我单击每个项目时,我在同一页面中有另一个 listView 包含新信息和 textview,我想显示以前的列表在文本视图中查看行,

请告诉我如何实现这一点,

提前致谢!

这是我的 xml 文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="######">


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:visibility="gone"
        android:text="test" />

    <TextView
        android:id="@+id/list_textview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        android:text="@string/no_message"
        android:textColor="#000000"
        android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
        android:gravity="center"></TextView>

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/listView" />
</LinearLayout>

这是我的 onItemClick :

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    chooseTest(testIds.get(position));

    String selectedTestId = testIds.get(position);

    Helpers.saveToSharedPreferences(getActivity(),
            Constants_Prefs.SELECTED_TOP_LEVEL_RECORD,
            Constants_Keys.SELECTED_TEST_ID,
            selectedTestId);

    FormTypeListFragment passDataTo = new FormTypeListFragment();

    Bundle bundle = new Bundle();
    bundle.putString("DATA", selectedTestId);

    passDataTo.setArguments(bundle);



}

【问题讨论】:

    标签: android json listview textview


    【解决方案1】:

    我看到您在问题中添加了 onItemClick,现在您需要做的就是从 FormTypeListFragment 中的捆绑包中访问数据:

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // init layout
        TextView listTextView = (TextView)view.findViewById(R.id.list_textview);
        Bundle bundle = getArguments();
        if (bundle != null) {
           String selectedTestId = bundle.getString("DATA");
           listTextView.setText(selectedTestId);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多