Coder Social home page Coder Social logo

Comments (5)

zhi1ong avatar zhi1ong commented on May 2, 2024
  1. 序列化参数支持是有计划的
  2. Fragment的顾虑是不知道应该由谁来指定这个Activity容器

from arouter.

yangyiRunning avatar yangyiRunning commented on May 2, 2024

@zhi1ong 作者你好,请问如何给fragment传递参数? 用提供的withXXX的API指定参数之后,在目的地对应的Fragment如何接收?

from arouter.

zhi1ong avatar zhi1ong commented on May 2, 2024

@yangyiRunning 正常 getArguments 或者 使用 @Autowired 注入

from arouter.

MartinDong avatar MartinDong commented on May 2, 2024

大哥别开枪,自己人,下面是Kotlin写法,

//获取指定的Fragment实例
val roomList = ARouter.getInstance()
                .build(ARouterPath.FRG_HOTEL_DETAIL_ROOM)
                //这里跟Activity传值一样,传输的Parcelable必须完整的重写那几个方法
                .withParcelable("mHouseInfo", mHouseInfo)
                .navigation() as Fragment

//然后再目标Fragment 中

@Route(path = ARouterPath.FRG_HOTEL_DETAIL_ROOM)
class RoomListFragment : BaseFragment {
    //@JvmField必须声明,否则编译不过去
    @JvmField
    @Autowired
    internal var mHouseInfo: HouseInfo? = null

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        ARouter.getInstance().inject(this)
        return super.onCreateView(inflater, container, savedInstanceState)
    }

}

from arouter.

junge89221 avatar junge89221 commented on May 2, 2024

@MartinDong 段友,你好
@route(path = "/mine/fragment")
class MineMainFragment : MVPBaseFragment<MineMainContract.IView, MineMainPresenter>(), MineMainContract.IView {

private val userInfo = UserInfo()
private val myOrder = MyOrder()
private val myHealthy = MyHealthy()
private val myFamilies = MyFamilies()
private val mySmartHome = MySmartHome()
private val myUptown = MyUptown()

private lateinit var messageNumView: TextView
private lateinit var refreshView: SwipeRefreshLayout
private lateinit var headerBackground: ImageView

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
    val rootView = inflater.inflate(R.layout.fragment_mine_main, container, false)
    EventBus.getDefault().register(this)
    initPartner(rootView)
    return rootView
}

然后我再:Fragment a = (Fragment)ARouter.getInstance().build("/mine/fragment").navigation();获取到的是个null。求解

from arouter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.