呼叫从ListViewItem的活动不失tabNavigation

编程入门 行业动态 更新时间:2024-10-27 03:31:01
本文介绍了呼叫从ListViewItem的活动不失tabNavigation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是小白在Android的发展,我尝试做一个简单的应用程序,有关某些产品和材料的细节。​​

I'm noob on android development, and im trying to do a simple app, for details about certain products and stuff.

我有以下布局:

<android.support.v4.app.FragmentTabHost xmlns:android="schemas.android/apk/res/android" android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="0"/> <FrameLayout android:id="@+android:id/realtabcontent" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"/> <TabWidget android:id="@android:id/tabs" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" /> </LinearLayout> </android.support.v4.app.FragmentTabHost>

有2个标签上tabHost导航,每一个扩展片段像这样

There are 2 tabs on that tabHost navigation, each one extends fragment like this

package co.smartmedia.vademecumtg; import co.smartmedia.vademecumtg.R; import android.support.v4.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class LineasTab extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.tab2, container, false); } }

在该导航我有ListView的第一个标签,并将该列表中的每个项目,必须调用另一项活动,将显示其详细信息。

In the first tab of that navigation i have a listView, and each item of that list, must call another activity that will show details about it.

即时调用从itemClickListener这个方法调用一个新的活动:

im calling a new activity by calling this method from an itemClickListener:

public void intentForMedView(int pos){ Log.w("debbuging", "start"); Intent intent = new Intent(getActivity().getApplicationContext(), MedViewActivity.class); intent.putExtra(EXTRA_MEDTITLE, array_sort.get(pos).getNombre()); intent.putExtra(EXTRA_MEDCONTENT, array_sort.get(pos).getLinea()); Log.w("debbuging", "send intent"+intent); startActivity(intent); }

和我打电话的活动如下:

and the activity that i'm calling is the following:

package co.smartmedia.vademecumtg; import co.smartmedia.vademecumtg.R; import android.app.Activity; import android.app.Fragment; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class MedViewActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_med_view); Intent intent = getIntent(); String title = intent.getStringExtra(MedicamentosTab.EXTRA_MEDTITLE); setTitle(title); TextView text = (TextView) findViewById(R.id.text); String lineName = intent.getStringExtra(MedicamentosTab.EXTRA_MEDCONTENT); text.setText(lineName); } }

我的问题是:

My problem is:

在详细活动显示,我的导航消失(在tabHost导航),而我不希望它....

When the detail activity is shown, my navigation Disappears (the tabHost navigation), and i don't want it....

一些提示或如何做到这一点?

some tips or ways to do it ?

thaks ...

thaks...

推荐答案

我现在的答案,要完成这种架构的方法,就是用 FragmentTransaction

I got the answer now, The way to accomplish this architecture, is to use FragmentTransaction

developer.android/guide/components/fragments.html

因为这是没有必要的另一项活动......刚刚与UI的片段播放。

Cause it isn't necessary another activity... just play with the fragments of the UI.

FragmentManager fragmentManager = getFragmentManager() FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

和照顾了Android版本的原因 android.support.v4.app.FragmentManager 无法转换为 android.app.FragmentManager

And take care with the android version cause android.support.v4.app.FragmentManager cannot cast to the android.app.FragmentManager

希望这是有益

更多推荐

呼叫从ListViewItem的活动不失tabNavigation

本文发布于:2023-11-06 16:18:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不失   ListViewItem   tabNavigation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!