Criei um Fragment no Android Studio, e nesse Fragment existe uma imageView e uma textView as quais quero editar pelo código. porém as duas não mudam...
public class HomeFragment extends Fragment {
private static String userkey;
public HomeFragment() {
// Required empty public constructor
}
public static HomeFragment newInstance(String key){
final HomeFragment homeFragment = new HomeFragment();
userkey=key;
return homeFragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home,container,false);
ImageView imageView = view.findViewById(R.id.qrImage);
TextView textView = view.findViewById(R.id.userCode);
QRCodeWriter writer = new QRCodeWriter();
try{
BitMatrix bitMatrix = writer.encode(userkey, BarcodeFormat.QR_CODE,512,512);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
Bitmap bmp = Bitmap.createBitmap(width,height,Bitmap.Config.RGB_565);
for(int z=0; z<width;z++){
for(int k=0; k<height; k++){
bmp.setPixel(z, k, bitMatrix.get(z, k) ? Color.BLACK : Color.WHITE);
}
}
imageView.setImageBitmap(bmp);
}
catch (WriterException e) {
e.printStackTrace();
}
textView.setText(userkey);
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home, container, false);
}