From your Activity
, just pass in this
as the Context
for your layout:
ProfileView pv = new ProfileView(this, null, temp, tempPd);
Afterwards you will have a Context
in the layout, but you will know it is actually your Activity
and you can cast it so that you have what you need:
Activity activity = (Activity) context;
Related Posts:
- Why fragments, and when to use fragments instead of activities?
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- How do I remove the title bar from my app?
- Font size of TextView in Android application changes on changing font size from native settings
- Error inflating class fragment
- Activity, AppCompatActivity, FragmentActivity, and ActionBarActivity: When to Use Which?
- How to build a horizontal ListView with RecyclerView
- Rotating a view in Android
- Android LinearLayout Gradient Background
- How to customize a Spinner in Android
- Android error “unable to find explicit activity class”
- How to remove title bar from the android activity?
- What is the meaning of android.intent.action.MAIN?
- What does ellipsize mean in android?
- What are the differences between LinearLayout, RelativeLayout, and AbsoluteLayout?
- What is the difference between “px”, “dip”, “dp” and “sp”?
- onSaveInstanceState () and onRestoreInstanceState ()
- How to inflate one view with a layout
- Fullscreen Activity in Android?
- Why this line xmlns:android=”http://schemas.android.com/apk/res/android” must be the first in the layout xml file?
- How do I get the currently displayed fragment?
- What exactly does fitsSystemWindows do?
- Determining translationX/Y values for ObjectAnimator; how to move a view to an exact screen position?
- What is the difference between gravity and layout_gravity in Android?
- Closing Application with Exit button
- How to change the color of a button?
- Can I underline text in an Android layout?
- Android: No Activity found to handle Intent error? How it will resolve
- Scrollview can host only one direct child
- Start an activity from a fragment
- How to remove title bar from the android activity?
- Android: remove or disable programmatically the Lock Screen on Samsung Galaxy S2 device
- Failed to find style ‘coordinatorLayoutStyle’ in current theme
- Android app unable to start activity componentinfo
- Dial pad to get phone number (with Android button images)
- Draw a transparent circle onto a filled android canvas
- Can’t start Eclipse – Java was started but returned exit code=13
- Install an apk file from command prompt?
- Unity remote 5 not working
- recyclerview No adapter attached; skipping layout
- recyclerview No adapter attached; skipping layout
- How to install APK from PC?
- ERROR Android emulator gets killed
- Session ‘app’ error while installing APK
- Android device does not show up in adb list
- Error “File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it”
- How to recompile with -Xlint:deprecation
- How do I get the dialer to open with phone number displayed?
- RecyclerView vs. ListView
- How to convert int to Integer
- Facebook login NullPointerException
- “Failed to install the following Android SDK packages as some licences have not been accepted” error
- How to use ScrollView in Android?
- What is com.google.android.gms.persistent and why is it always using the CPU?
- Parcelable encountered IOException writing serializable object getactivity()
- Google Sceneform – Is it deprecated? Any replacement?
- onActivityResult() not called
- “com.example is restricted” when uploading APK to Play Store
- Android Studio: Unable to obtain result of ‘adb version’
- Android simple alert dialog
- The activity must be exported or contain an intent-filter
- Avoid passing null as the view root (need to resolve layout parameters on the inflated layout’s root element)
- How do we use runOnUiThread in Android?
- Error getGoogleAppId failed with status: 10 Android KitKat – GCM and Google Drive
- “Bitmap too large to be uploaded into a texture”
- How do you close/hide the Android soft keyboard programmatically?
- Picasso v/s Imageloader v/s Fresco vs Glide vs Coil
- Save bitmap to location
- Android : When do we use getIntent()?
- onActivityResult() not called
- How to resolve the “ADB server didn’t ACK” error?
- How to implement onBackPressed() in Fragments?
- Does anyone know the what’s causing “Package name is not a valid package name” when adding a new layout?
- How to completely uninstall Android Studio from windows(v10)?
- DELETE_FAILED_INTERNAL_ERROR Error while Installing APK
- How to install Google Play Services in a Genymotion VM (with no drag and drop support)?
- Failed to find Build Tools revision 23.0.1
- Running Node.Js on Android
- Android Device not recognized by adb
- Delete child from firebase [duplicate]
- How to authorize and accept ADB RSA key with broken touch screen on Android
- why android studio show error of “Missing constraints in constraintlayout”?
- How to make layout with rounded corners..?
- Cannot resolve method getApplicationContext()
- Change Orientation of Bluestack : portrait/landscape mode
- Android Fragment no view found for ID?
- How to use ADB Shell when Multiple Devices are connected? Fails with “error: more than one device and emulator”
- How to disable action bar permanently
- Manifest Merger failed with multiple errors in Android Studio
- hardcoded string “row three”, should use @string resource
- E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7519c0
- How to handle .tar.md5 files
- Why am I getting Permission Denied when trying to push a Sqlite file to my rooted Android device?
- Android studio- “SDK tools directory is missing”
- adb devices return error: protocol fault (no status)
- How to get text from EditText?
- android.widget.Switch – on/off event listener?
- SDK Location not found in android studio