我目前正在尝试在我的阵列适配器的左侧绘制一个项目,但出于某种原因,它似乎只在消失之前出现了几帧。
这里是...的代码
ArrowView
public class ArrowView extends View {
private Path path;
private Paint paint;
private void init() {
path = new Path();
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(ContextCompat.getColor(getContext(), R.color.white));
paint.setStyle(Paint.Style.FILL);
}
public ArrowView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
path.setFillType(Path.FillType.EVEN_ODD);
path.moveTo(0, 0);
path.lineTo(0, getHeight());
path.lineTo(getWidth(), getHeight() / 2);
path.lineTo(0, 0);
path.close();
canvas.drawPath(path, paint);
Log.d("arroview", "onDraw called");
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}
}
我的片段:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater
.inflate(R.layout.fragment_first_use_get_started, container, false);
Button button = (Button) rootView.findViewById(R.id.leave_first_time_screen_button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().finish();
}
});
ListView listView = (ListView) rootView.findViewById(R.id.get_started_list_view);
listView.setAdapter(new ArrayAdapter<>(getContext(), R.layout.adapter_get_started, R.id.get_start_description_text_view, functionalityStrings));
listView.setDividerHeight(0);
listView.setEnabled(false);
return rootView;
}
最后,我的适配器布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:layout_height="match_parent"
android:orientation="horizontal">
<com.example.ArrowView
android:layout_width="0dp"
android:layout_weight=".25"
android:layout_height="match_parent" />
<TextView
android:id="@+id/get_start_description_text_view"
android:layout_weight=".75"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
onDraw只被调用一次,在我的测试中,有几次以某种方式呈现三角形(无法再现......)。我怀疑它必须与ArrayAdapter如何工作有关?
谢谢!
答案 0 :(得分:0)
尝试添加
Map<String, Object> params = new HashMap<>();
params.put(JRParameter.REPORT_LOCALE, Locale.CHINA);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
构造函数中的