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

no module named 'androidx' #73

Open
1357koushik opened this issue Mar 9, 2021 · 0 comments
Open

no module named 'androidx' #73

1357koushik opened this issue Mar 9, 2021 · 0 comments

Comments

@1357koushik
Copy link

i converted the below java code
`import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

// One Button 
Button BSelectImage; 

// One Preview Image 
ImageView IVPreviewImage; 

// constant to compare 
// the activity result code 
int SELECT_PICTURE = 200; 

@Override
protected void onCreate(Bundle savedInstanceState) { 
	super.onCreate(savedInstanceState); 
	setContentView(R.layout.activity_main); 

	// register the UI widgets with their appropriate IDs 
	BSelectImage = findViewById(R.id.BSelectImage); 
	IVPreviewImage = findViewById(R.id.IVPreviewImage); 

	// handle the Choose Image button to trigger 
	// the image chooser function 
	BSelectImage.setOnClickListener(new View.OnClickListener() { 
		@Override
		public void onClick(View v) { 
			imageChooser(); 
		} 
	}); 
} 

// this function is triggered when 
// the Select Image Button is clicked 
void imageChooser() { 

	// create an instance of the 
	// intent of the type image 
	Intent i = new Intent(); 
	i.setType("image/*"); 
	i.setAction(Intent.ACTION_GET_CONTENT); 

	// pass the constant to compare it 
	// with the returned requestCode 
	startActivityForResult(Intent.createChooser(i, "Select Picture"), SELECT_PICTURE); 
} 

// this function is triggered when user 
// selects the image from the imageChooser 
public void onActivityResult(int requestCode, int resultCode, Intent data) { 
	super.onActivityResult(requestCode, resultCode, data); 

	if (resultCode == RESULT_OK) { 

		// compare the resultCode with the 
		// SELECT_PICTURE constant 
		if (requestCode == SELECT_PICTURE) { 
			// Get the url of the image from data 
			Uri selectedImageUri = data.getData(); 
			if (null != selectedImageUri) { 
				// update the preview image in the layout 
				IVPreviewImage.setImageURI(selectedImageUri); 
			} 
		} 
	} 
} 

}
`
and abstain the below python code

`#!/usr/bin/env python
""" generated source for module new """
import androidx.appcompat.app.AppCompatActivity

import android.content.Intent

import android.net.Uri

import android.os.Bundle

import android.view.View

import android.widget.Button

import android.widget.ImageView

class MainActivity(AppCompatActivity):
""" generated source for class MainActivity """
# One Button
BSelectImage = Button()

#  One Preview Image 
IVPreviewImage = ImageView()

#  constant to compare 
#  the activity result code 
SELECT_PICTURE = 200

def onCreate(self, savedInstanceState):
    """ generated source for method onCreate """
    super(MainActivity, self).onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    #  register the UI widgets with their appropriate IDs 
    self.BSelectImage = findViewById(R.id.BSelectImage)
    self.IVPreviewImage = findViewById(R.id.IVPreviewImage)
    #  handle the Choose Image button to trigger 
    #  the image chooser function 
    self.BSelectImage.setOnClickListener(View.OnClickListener())

#  this function is triggered when 
#  the Select Image Button is clicked 
def imageChooser(self):
    """ generated source for method imageChooser """
    #  create an instance of the 
    #  intent of the type image 
    i = Intent()
    i.setType("image/*")
    i.setAction(Intent.ACTION_GET_CONTENT)
    #  pass the constant to compare it 
    #  with the returned requestCode 
    startActivityForResult(Intent.createChooser(i, "Select Picture"), self.SELECT_PICTURE)

#  this function is triggered when user 
#  selects the image from the imageChooser 
def onActivityResult(self, requestCode, resultCode, data):
    """ generated source for method onActivityResult """
    super(MainActivity, self).onActivityResult(requestCode, resultCode, data)
    if resultCode == RESULT_OK:
        #  compare the resultCode with the 
        #  SELECT_PICTURE constant 
        if requestCode == SELECT_PICTURE:
            #  Get the url of the image from data 
            if None != selectedImageUri:
                #  update the preview image in the layout 
                self.IVPreviewImage.setImageURI(selectedImageUri)

`

and got no module named 'androidx'

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

No branches or pull requests

1 participant