I have a problem with AlertDialog.Builder, I am trying to find the right context to give to builder = AlertDialog.Builder(this) but I keep having this error message Type mismatch. Required: Context Found: ProfilFragment
import : androidx.appcompat.app.AlertDialog
I really don't know at this point what context to use instead.
Thank you
You can access context from a fragment by using requireContext(). So pass requireContext() instead of this in the AlertDialog.Builder
Related
Ok, I am officially confused.
In Shiro I have my own realm (DatastoreRealm) that extends AuthorizingRealm. In my DatastoreRealm, I have the method "clearCachedAuthorizationInfo" which allows me to clear the users permissions, etc, (and then re-check) when those permissions change on the fly.
In order to get to that method, I have to get access to my DatastoreRealm object.
I do this in the following way...
private static Realm lookupRealm(String realmName) {
SecurityManager securityManager = SecurityUtils.getSecurityManager();
RealmSecurityManager realmSecurityManager = (RealmSecurityManager) securityManager;
Collection<Realm> realms = realmSecurityManager.getRealms();
for (Realm realm : realms) {
if (realm.getName().equalsIgnoreCase(realmName)) {
log.info("look up realm name is : " + realm.getName());
return realm;
}
}
return null; }
This seems to work fine. It returns me a "DatastoreRealm" object.
Although when I call this method, I am forced to do the following...
DatastoreRealm dsRealm = (DatastoreRealm) lookupRealm("rfRealm");
Which throws a "ClassCastException" telling me...
rf.gae.DatastoreRealm cannot be cast to rf.gae.DatastoreRealm
How/Why is this happening???
If I DON'T cast, and simply use the "Realm" object, the "clearCachedAuthorizationInfo" is not available to me!
Thanks in advance for the help!
Well with a bit more digging, I figured out the problem.
The web framework that I'm using has the ability to "hot reload" classes which prevents having to restart the server on each code change.
The problem with this is that a new classloader loads the edited class, and thus when a cast is attempted, the class in memory cannot be cast to the new class loaded by the classloader!
For classes to be cast, they have to be of the same type and loaded by the same classloader.
Turning this feature off corrected my casting issue.
When I'm trying to open new Panel after button tap I always get this error:
Uncaught Error: [ERROR][Ext.Container#factoryItem] Invalid config, must be a valid config object
Here is the function (Located in custom controller):
push : function(navigationView, viewClass) {
navigationView.push(viewClass);
}
And this is how it's called (Located in controller class that extends custom controller):
push(this.getNvw_main(), 'First.view.HomePage');
Thanks for help in advance.
Well, view must be instatiated in order to pushed:
push : function(navigationView, viewClass) {
var view = Ext.ClassManager.instantiate(viewClass);
navigationView.push(view);
}
For your second argument you should probably pass an object with the configs like so: {xtype:'homepage'}. That is assuming that your First.view.Homepage has an alias widget.homepage.
I am using RhinoMocks 3.6 and would like to use the multimock feature to implement both a class and a interface.
var mocks = new MockRepository();
var project = mocks.StrictMultiMock(
typeof(Project),
typeof(INotifyCollectionChanged));
using (mocks.Record())
{
((INotifyCollectionChanged)project).CollectionChanged += null;
LastCall.Constraints(Is.NotNull()).Repeat.Any();
}
The LastCall is working though. I get this message :
System.InvalidOperationException : Invalid call, the last call has been used or no call has been made (make sure that you are calling a virtual (C#) / Overridable (VB) method).
What am I doing wrong here??
Have you actually checked that the Project class has methods you can override as the error message indicates? I'll assume you have. :-)
I'd suggest you switch to using the AAA syntax instead of record/replay as shown here:
I assume you're wanting to know if the class under test reacts the right way when the CollectionChanged event is fired? If that's the case, you can do it something like this:
var project = MockRepository.GenerateMock<Project, INotifyPropertyChanged>();
project.Expect(p => p.SomeMethod())
.Repeat.Any()
.Raise(p => ((INotifyCollectionChanged)p).CollectionChanged += null,p,new NotifyCollectionChangedEventArgs());
I am new Web App development using Flex Builder 3 and currently I am facing the following problem:
Attached is a code snippet from the mxml file:
<mx:Script>
<![CDATA[
import com.bx.Char10;
import com.bx.A;
[Bindable] private var inputParam:A = new A()
inputParam.CustNumber.char10 = '0123456789'
}
]]>
</mx:Script>
This Gives a compile error
1120 Access of undefined property inputParam
However if I replace
inputParam.CustNumber.char10 = '0123456789'
with
private function set():void
{
inputParam.CustNumber.char10 = '0123456789'
}
The compile error goes away.
My Question is :
How can I remove this Compilation Error without using the workaround I did?
Hmm, I don't believe that one can execute arbitrary statements directly inside a class body. (The "Script" tag's contents are treated as if they were directly inside the class body).
Only function definitions or variable property definitions are allowed.
A different work-around to use is to pass the information through the constructor of the variable property you're interested in.
[Bindable] private var inputParam:A = new A('0123456789')
I try to call skype instance by COM on F#.
A aim is get mood message.
test.fs
// Import skype4com Api
open SKYPE4COMLib
type SKYPE4COM =
new() = new SKYPE4COM()
let GetMood =
let aSkype = new SKYPE4COM
mood <- aSkype.CurrentUserProfile.MoodText
mood
But when build(before too),error occur.
Incomplete structured construct at or before this point in expression
Thanks in advance.
this is next version what I think.
test01.fs
// Import skype4com Api
open SKYPE4COMLib
let GetMood =
let aSkype = new SKYPE4COMLib() // line 1
mood <- aSkype.CurrentUserProfile.MoodText // line 2
mood // line 3
error message(when building).
line in 1:error FS0039: The type 'SKYPE4COMLib' is not defined
line in 2:error FS0039: The value or constructor 'mood' is not defined
line in 3:error FS0039: The value or constructor 'mood' is not defined
also like that...
Your code has several issues. First of all, your constructor for the SKYPE4COM class appears to be recursive (?!), which is going to cause a stack overflow if you try to create an instance. Secondly, the error that you're receiving is because you are using the new operator, but you haven't completed the call to the constructor (i.e. you need to apply the constructor using parentheses: let aSkype = new SKYPE4COM()). Even then, though, you've got another issue because your type doesn't expose a CurrentUserProfile property, so your code still won't work.
Try something like this:
open SKYPE4COMLib
let getMood() =
SkypeClass().CurrentUserProfile.MoodText
Consider using a Type Extension to add a member to an already existing type:
open SKYPE4COMLib
type SKYPE4COMLib with
member this.GetMood() =
aSkype.CurrentUserProfile.MoodText
This would allow you to access GetMood as if it were a member function defined on the SKYPE4COMLib type:
let x = new SKYPE4COMLib()
printfn "%A" (x.GetMood())