android-fragments

Error in my Fragment: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference [duplicate]

不羁的心 提交于 2021-02-11 14:53:11
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 2 years ago . I try to create a ListView which showes my Pojos called "Baustelle". I wrote a Adapter and a ViewHolder as I learned it in school but the difference is that we only did it for the MainActivity in my school. Now i tried to use a Fragment for it but I always get this Error: "Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a

How to manage bottomNavigation from fragment?

依然范特西╮ 提交于 2021-02-11 14:47:39
问题 I'm trying to set navController to bottomNavigation, but it's requires activity, the problem is my borromNavigation hosted in fragment, so i don't have activity instance. I've tried bottom_nav_view.setupWithNavController(findNavController()) and: val host = Navigation.findNavController(this.activity!!.parent, R.id.my_nav_host_fragment) bottom_nav_view.setupWithNavController(host) home_fragment.xml: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns

Android get view of fragment in activity [duplicate]

徘徊边缘 提交于 2021-02-11 14:34:08
问题 This question already has answers here : findViewById in Fragment (35 answers) Closed 8 months ago . I have an activity, let's call it A , and it launches a fragment like so: remoteFragment = new RemoteFragment(); getSupportFragmentManager() .beginTransaction() .replace(R.id.frameLayout_remote_activity, remoteFragment) .commit(); my remoteFragment looks something like this: public Button okBtn; public RemoteFragment() { // Required empty public constructor } @Override public View onCreateView

Accesing local server using Resharp

最后都变了- 提交于 2021-02-11 13:41:54
问题 I am in progress of implementing a searchView but before I do that I would like to successfully reach my local rest api (written using asp.net core). I found a package named RestSharp which seems to make consuming a rest api very simple. Right now I am stuck at accessing my api from my Xamarin.Android application. I am using a fragment which makes use of google maps, at the OnCreateView lifecycle method I am calling a addData which is supposed to reach out to my api: public override View

How to make my Fragment make use of my Activity Data?

孤街醉人 提交于 2021-02-11 12:48:53
问题 I have an Activity hosting 3 Fragments, my activity contains some data that I want my first fragment to use. I tried invoking the following method so that the activity can communicate with the fragment: FirstFragment fragmentFirst = (FirstFragment) getSupportFragmentManager().findFragmentById(R.id.firstFragment); assert fragmentFirst != null; fragmentFirst.doSomething("some param"); For the activity class and: public void doSomething(String param) { // do something in fragment } For the

Observing MediatorLiveData Issue

穿精又带淫゛_ 提交于 2021-02-11 12:32:23
问题 I have the following LiveData variables in my ViewModel (simplified example): val currentUser : LiveData<UserObject> val allSites : LiveData<ArrayList<SiteObject>> val filterSitesForUser : LiveData<Boolean> val orderSitesByField : LiveData<String> val orderSitesDirection : LiveData<Query.Direction> val searchFilterSitesText : LiveData<String> I'm trying to use MediatorLiveData to have one 'stream' of data connecting to my RecyclerView . I therefore also have the following code in the

Why can't I upload a picture from gallery in my android app, if the picture was taken with the camera app from android?

浪尽此生 提交于 2021-02-11 12:22:27
问题 I want to upload an image from gallery and show it on my Android app. This works fine if I select an image from the screenshot folder for example. But when I select an image from the folder where the pics, taken with the phone camera, are stored, it does not work. public void UploadPicture(View v) { Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto , 1); protected void onActivityResult(int

Why can't I upload a picture from gallery in my android app, if the picture was taken with the camera app from android?

前提是你 提交于 2021-02-11 12:21:14
问题 I want to upload an image from gallery and show it on my Android app. This works fine if I select an image from the screenshot folder for example. But when I select an image from the folder where the pics, taken with the phone camera, are stored, it does not work. public void UploadPicture(View v) { Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto , 1); protected void onActivityResult(int

Creating google maps v2 in a fragment using Navigation Drawer

蓝咒 提交于 2021-02-11 07:09:40
问题 I am trying to create a map in a Fragment but keep getting this error: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.SupportMapFragment.getMap()' on a null object reference at com.new.newapps.activity.MapsFragment.initilizeMap(MapsFragment.java:41) at com.new.newapps.activity.MapsFragment.onResume(MapsFragment.java:52) I am not sure how to fix this. Please have a look at my code below. MapsFragment class:

Creating google maps v2 in a fragment using Navigation Drawer

戏子无情 提交于 2021-02-11 07:07:40
问题 I am trying to create a map in a Fragment but keep getting this error: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.SupportMapFragment.getMap()' on a null object reference at com.new.newapps.activity.MapsFragment.initilizeMap(MapsFragment.java:41) at com.new.newapps.activity.MapsFragment.onResume(MapsFragment.java:52) I am not sure how to fix this. Please have a look at my code below. MapsFragment class: