【发布时间】:2019-08-01 13:41:38
【问题描述】:
可能我的问题不是很好,但我真的不知道如何正确地问。
我想做什么:
public interface cooleInterface {
void soCoolFunction(String a);
}
我的第一个问题是,如何定义方法? 我想在 Activity 中定义方法,例如:
public void soCoolFunction(String a){
Log.d(TAG, "You Logged " + a);
}
现在我想从像这样的线程调用它
public class WhatEver extends Thread implements cooleInterface{
public void run(){
@override
soCoolFunction("Hello");
这甚至可能吗?或者如何在不使用静态的情况下调用其他没有实例的类中的方法?
【问题讨论】:
-
你可以在WhatEver类中传递cooleInterface的实例。