我必须编辑一个具有自定义视图的软件,当我尝试编辑布局xml时,Eclipse说我:
在Eclipse中显示时,在自定义视图中使用View.isInEditMode()来跳过代码
但我不知道应用程序中必须使用isIndditMode()的方式和位置
我的xml文件是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff000000"
>
<TextView
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textSize="32dip"
android:scrollbars="none"
android:lines="1"
android:freezesText="true"
android:textColor="@color/result"
/>
<EditText
android:id="@+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="28dip"
android:scrollbars="none"
android:singleLine="true"
android:autoText="false"
android:imeOptions="flagNoEnterAction|flagNoExtractUi"
/>
<ListView
android:id="@+id/history"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:cacheColorHint="#ff000000"
android:choiceMode="singleChoice"
android:scrollbarStyle="outsideInset"
android:scrollbars="none"
/>
<calculator.GraphView
android:id="@+id/graph"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:visibility="gone"
/>
<include layout="@layout/keyboard" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的GraphView是
public class GraphView extends View implements Grapher,
ZoomButtonsController.OnZoomListener,
TouchHandler.TouchHandlerInterface {
private int width, height;
private Matrix matrix = …Run Code Online (Sandbox Code Playgroud) 在Android Studio中,布局编辑器无法在xml中预览自定义视图.
很简单的例子:
public class MyCustomView extends FrameLayout {
public MyCustomView(Context context) {
super(context);
}
public MyCustomView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyCustomView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
}
Run Code Online (Sandbox Code Playgroud)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<com.myprojectxxx.view.MyCustomView
android:layout_width="48dp"
android:layout_height="48dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Android Studio总是说,
渲染问题
找不到以下类:
- com.myprojectxxx.view.MyCustomView(修复构建路径,创建类)
提示:尝试构建项目
当然,我有那门课.如果我单击"创建类",它会抱怨同一个类已经存在.如果我重建该项目,没有任何改变.
而且,是的,该项目在我的Android设备上运行良好.此外,它在Eclipse ADT中呈现得非常好.但是,在Android Studio中,它总是说"CLASSES可能无法找到".
Android Studio无法使用自定义视图预览xml文件?这有什么问题?
java android android-custom-view android-layout android-studio