Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants