当我的布局包含自定义视图时,如何获取自定义视图的内容以显示在Android Studio的预览窗口中?
我有一个基于LinearLayout的自定义视图:
CompletableFuture.supplyAsync(()->comp1()) // start in common-pool
.thenApplyAsync(order -> io1(order),ioPool) // lets say this is IO operation
.thenApplyAsync(order -> comp2(order)) // switch back to common-pool
.thenApplyAsync(order -> io2(order),ioPool); // another io
它会夸大其根是averageTriple :: (Double, Double, Double) -> Double
averageTriple (x,y,z) = ...
averageTriples :: [(Double, Double, Double)] -> [Double]
averageTriples ts = ... -- use averageTriple here
标签的布局:
class MyCustomView:LinearLayout {
constructor(context:Context?):super(context)
constructor(context:Context?, attrs:AttributeSet?):super(context, attrs) {
initialize(context, attrs)
}
constructor(context:Context?, attrs:AttributeSet?, defStyleAttr:Int):super(context, attrs, defStyleAttr) {
initialize(context, attrs)
}
constructor(context:Context?, attrs:AttributeSet?, defStyleAttr:Int, defStyleRes:Int):super(context, attrs, defStyleAttr, defStyleRes) {
initialize(context, attrs)
}
fun initialize(context:Context?, attrs:AttributeSet?) {
LayoutInflater.from(context).inflate(R.layout.my_custom_view_layout, this)
}
}
我将视图作为元素包含在主布局文件中:
<merge/>
当我在预览窗口中查看主布局时,自定义视图的内容不可见。我希望能够看到我的自定义视图,包括“ hello world” TextField。我该如何实现?
答案 0 :(得分:0)
您可以尝试重建项目,但我认为您需要以编程方式添加其他视图。
CustomLayout extends LinearLayout{
public CustomLayout(Context context) {
super(context);
//Add your view to this layout
this.add(new MyCustomFirstView());
//Add other views the same way and customize LayoutParams here...
}
}
我希望它能对您有所帮助:)