Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

cannot be used in fragment #105

Open
Vishal-Likhitkar opened this issue Jun 6, 2021 · 0 comments
Open

cannot be used in fragment #105

Vishal-Likhitkar opened this issue Jun 6, 2021 · 0 comments
Assignees
Labels

Comments

@Vishal-Likhitkar
Copy link

package com.appy.countrydetail;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.mukesh.countrypicker.Country;
import com.mukesh.countrypicker.CountryPicker;
import com.mukesh.countrypicker.OnCountryPickerListener;

public class MainActivity extends AppCompatActivity implements OnCountryPickerListener {

private TextView countryname,countryiso,countrydialcode,countrycurrency;
private ImageView countryflag;
private Button pickcountrybtn;
private CountryPicker countryPicker;
private Activity mActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    intialize();
    setListener();
}
private void setListener() {
    pickcountrybtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            countryPicker.showDialog(getFragmentManager());
        }
    });
}
private  void intialize() {
    countryname = findViewById(R.id.selectedcountryname);
    countryiso = findViewById(R.id.Selectedcountryisocode);
    countrydialcode = findViewById(R.id.Selectedcountrydialcode);
    pickcountrybtn = findViewById(R.id.countrypickerbutton);
    countryflag = findViewById(R.id.country_flag);
    countrycurrency = findViewById(R.id.Selectedcountrycurrency);
    countryPicker = new CountryPicker.Builder().with(this)
            .listener(this)
            .build();
}
@Override
public void onSelectCountry(Country country){
    countryflag.setImageResource(country.getFlag());
    countrydialcode.setText(country.getDialCode());
    countryiso.setText(country.getCode());
    countryname.setText(country.getName());
    countrycurrency.setText(country.getCurrency());
}

}

I am getting error here
countryPicker.showDialog(getFragmentManager());

And the error is
countryPicker.showDialog(getFragmentManager());
^
class file for android.support.v4.app.FragmentManager not found

when I add this libraray is still showing error

Screenshot (5)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants