interface

Android: error with on fragment interaction Listener

烂漫一生 提交于 2019-12-19 02:58:08
问题 I have been looking at stackoverflow to solve my problem and found something pretty good, but it does not work for me or I am to stupid to see it (How to implement OnFragmentInteractionListener) I want to place a fragment inside a Frame, so I created it and so on. I have to implenet an interface and its method. I (think) I did it, but my App crashes everytime... *Edit: My App crashes, when I call openHome or openRecommended, the onCreate method works, I get these errors, but everything is

Private Interfaces

浪子不回头ぞ 提交于 2019-12-19 02:54:13
问题 How can we use the methods of a private interface in our code? Abstract classes are something which cannot be instantiated. So, if we need to use methods of abstract class, we can inherit them and use their methods. But, when we talk about interfaces, we need to implement them to use their methods. 回答1: The private keyword means "anyone in the same class": public class Foo { private interface X {...} private class X1 implements X {...} } This means all classes declared inside of Foo can use

How do I know when an interface is directly implemented in a type ignoring inherited ones?

孤街醉人 提交于 2019-12-19 02:02:36
问题 The issue appears is when I have a class implementing an interface, and extending a class which implements an interface: class Some : SomeBase, ISome {} class SomeBase : ISomeBase {} interface ISome{} interface ISomeBase{} Since typeof(Some).GetInterfaces() returns and array with ISome and ISomeBase, i'm not able to distinguish if ISome is implemented or inherited (as ISomeBase). As MSDN I can't assume the order of the interfaces in the array, hence I'm lost. The method typeof(Some)

Spring Dependency injection for interfaces

好久不见. 提交于 2019-12-19 00:58:27
问题 Well I've been watching some tutorials about Spring dependency injection as well as MVC, but I still seem to not understand how we can instantiate classes specifically? I mean if for instance I have a variable @Autowired ClassA someObject; How can I make spring create someObject as an Instance of ClassB which would extend ClassA? like someObject = new ClassB(); I don't really understand how it works in spring, does the ContextLoaderListener do it automatically or do we have to create some

How can I serialize an object that has an interface as a property?

蓝咒 提交于 2019-12-18 22:58:13
问题 I have 2 interfaces IA and IB. public interface IA { IB InterfaceB { get; set; } } public interface IB { IA InterfaceA { get; set; } void SetIA(IA value); } Each interfaces references the other. I am trying to serialize ClassA as defined below. [Serializable] public class ClassA : IA { public IB InterfaceB { get; set; } public ClassA() { // Call outside function to get Interface B IB interfaceB = Program.GetInsanceForIB(); // Set IB to have A interfaceB.SetIA(this); } } [Serializable] public

Using an interface as the model type of a partial view + data annotations

喜你入骨 提交于 2019-12-18 22:32:49
问题 I have a case where a complex partial view needs different validation of fields depending on where the partial view is used. I thought I could get around this by making the partial view take an interface as the model type and implementing two different ViewModels based on the interface. The data annotations in the two ViewModels would be different. I would then supply an instance of the correct ViewModel to the partial view. But what I'm finding is that the only annotations that are

In Kotlin, how can I work around the inherited declarations clash when an enum class implements an interface?

无人久伴 提交于 2019-12-18 21:18:10
问题 I define an enum class that implements Neo4j's RelationshipType : enum class MyRelationshipType : RelationshipType { // ... } I get the following error: Inherited platform declarations clash: The following declarations have the same JVM signature (name()Ljava/lang/String;): fun <get-name>(): String fun name(): String I understand that both the name() method from the Enum class and the name() method from the RelationshipType interface have the same signature. This is not a problem in Java

Logging from default interface methods

有些话、适合烂在心里 提交于 2019-12-18 18:47:30
问题 Salut to all Java gurus! Since Java8 we can have default implementations in interfaces (yay!). However problem arises when you want to log from default method. I have a feeling that it is not wise to call .getLogger() every time I want to log something in a default method. Yes, one can define static variable in an interface - but that is not a good practice for interfaces anyway + it exposes the logger (must be public). Solution I have at the moment: interface WithTimeout<Action> { default

Optional method in Java Interface

依然范特西╮ 提交于 2019-12-18 18:47:11
问题 I have an interface with several method definitions, and I would not like to require some of them. Is this possible? if so, how can i implement this? I have tried setting an annotation of @Optional but this doesn't seem to work. Do i have to define the Optional annotation somewhere? 回答1: Although I agree with the other answers, one should note that such optional methods exist in the JDK. For example, List.add() is optional. Implementations must throw an UnsupportedOperationException if they

ASP.NET: Unfamiliar with Interfaces

社会主义新天地 提交于 2019-12-18 18:32:16
问题 I'm building a decent sized application in ASP.NET/VB.NET with various objects... I've never used interfaces before, and a fellow programmer balked when I mentioned this to him. Can anyone give me a quick overview on how they're used, what they're used for, and why I would use them? Maybe I don't need to use them for this project, but if they would help, I surely would love to try. Thanks so much! 回答1: Once you "get" interfaces, OOP really falls into place. To put it simply, an interface