用Android的textview为例
一、创建提供出去的View
public class SDKView implements PlatformView {
private TextView textView;
public SDKView(Context context,String text) {
textView = new TextView(context);
textView.setText(text);
}
@Override
public View getView() {
return textView;
}
@Override
public void dispose() {
}
}
二、创建 PlatformViewFactory、其实类似RN的ViewManager
public class SDKViewFactory extends PlatformViewFactory {
private static final String TAG = "PlatformViewFactory";
public SDKViewFactory(MessageCodec<Object> createArgsCodec) {
super(createArgsCodec);
}
@Override
public PlatformView create(Context context, int i, Object o) {
Map<String,Object> param = (Map<String,Object>)o;
String text = (String)param.get("text");
Log.d(TAG, "create: "+text);