long1eu / long1eu/SpaceTabLayout

How to send data from Activity to Fragment?

Open
#42 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.6k
Forks
265
PR merge metrics
No merged PRs in 30d

Description

MyActivity onCreate
```
Bundle bundle=new Bundle();
bundle.putString("name", "From Activity");
bundle.putInt("id", 4);
FragmentA fragobjA = new FragmentA();
fragobjA.setArguments(bundle);

```

and this FragmentA
```
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_a, container, false);
Bundle bundle = this.getArguments();
if (bundle != null) {
nomor = bundle.getInt("id", 0);
info= bundle.getString("name");

};
return rootView;

} .....
```
error nomor and id value : null

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing MyActivity's onCreate flow and the FragmentA lifecycle, especially where FragmentA is attached after its arguments are set. Reproduce the null values and verify the argument values are available in FragmentA before considering the issue resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.