现在我正面临着这个问题.我在xAx中得到的重复值是第一个和最后一个.图形值不是根据各个x轴值的值.第二个问题是,如果我想显示不在float中但在int Rounded中的值,并将它们的颜色更改为白色.
ArrayList<String> xlabels = new ArrayList<String>();
xlabels.add("Jan");
xlabels.add("Feb");
xlabels.add("Mar");
xlabels.add("Apr");
xlabels.add("May");
xlabels.add("Jun");
ArrayList<String> values = new ArrayList<String>();
values.add("1");
values.add("20");
values.add("10");
values.add("80");
values.add("90");
values.add("24");
showLineChart(clickChart,xlabels,values,mColors[3]);
Run Code Online (Sandbox Code Playgroud)
showLineChart方法:
private void showLineChart(LineChart chart,final List<String> xLabels, List<String> values,int color){
List<Entry> entries = new ArrayList<Entry>();
for(int i=0;i<values.size();i++){
entries.add(new Entry(i, Integer.parseInt(values.get(i))));
}
LineDataSet dataSet = new LineDataSet(entries, "Numbers");
dataSet.setLineWidth(1.75f);
dataSet.setCircleRadius(5f);
dataSet.setCircleHoleRadius(2.5f);
dataSet.setColor(Color.WHITE);
dataSet.setCircleColor(Color.WHITE);
dataSet.setHighLightColor(Color.WHITE);
dataSet.setDrawValues(true);
LineData data = new LineData(dataSet);
((LineDataSet) data.getDataSetByIndex(0)).setCircleColorHole(color);
chart.getDescription().setEnabled(false);
chart.setDrawGridBackground(false);
chart.setTouchEnabled(true);
chart.setBorderColor(Color.WHITE);
chart.setDragEnabled(true);
chart.setScaleEnabled(true);
chart.setPinchZoom(false);
chart.setBackgroundColor(color);
YAxis yAxisLeft = chart.getAxisLeft();
yAxisLeft.setTextColor(Color.WHITE);
yAxisLeft.setAxisLineColor(Color.WHITE); …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我尝试使用Bruicetoo 的WheelPicker,它的工作正常,但是当我在其内部ScrollView停止响应时,仅滚动了活动,但无法滚动WheelPicker。我也尝试android:nestedScrollingEnabled="true"过选择器,但是没有用。SDK的最低版本为21,目标版本为23。
更新的代码
布局:
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="90dp"
android:layout_marginTop="20dp">
<com.bruce.pickerview.LoopView
android:id="@+id/loop_view"
android:layout_width="50dp"
android:layout_height="90dp"
android:layout_below="@+id/calendar_view"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:nestedScrollingEnabled="true"
app:canLoop="true"
app:centerTextColor="#ff000000"
app:drawItemCount="7"
app:initPosition="3"
app:lineColor="@color/PrimaryBlue"
app:textSize="12sp"
app:topBottomTextColor="#ffafafaf" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
码:
loopView = (LoopView) findViewById(R.id.loop_view);
loopView.setInitPosition(2);
loopView.setCanLoop(false);
loopView.setLoopListener(new LoopScrollListener() {
@Override
public void onItemSelect(int i) {
Toast.makeText(RegisterRoomActivity.this, StartHr.get(i), Toast.LENGTH_LONG).show();
}
});
loopView.setTextSize(25);//must be called before setDateList
loopView.setDataList(StartHr);
Run Code Online (Sandbox Code Playgroud) 我有一个NestedScrollView父母和片段包含googleMap其子.当我在地图中向下或向上滚动时,NesetdScrollView会滚动,我无法在地图内滚动.直到现在我已经通过创建透明图像尝试了堆栈溢出的解决方案,但它对我没有用.
XML:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/car_progress"
android:id="@+id/nested_scroll"
android:visibility="gone"
>
............
............
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/first_section"
android:visibility="gone"
android:id="@+id/map_wrapper"
android:orientation="vertical"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dealer_location"
android:textAllCaps="true"
android:textColor="@color/colorPrimary"
style="@style/BoldStyle"
android:layout_marginLeft="@dimen/single_title_dimen"
android:layout_marginRight="@dimen/single_title_dimen"
android:id="@+id/dealer_head"
/>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_below="@+id/dealer_head"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imagetrans"
android:layout_alignTop="@+id/map"
android:layout_alignBottom="@+id/map"
android:layout_alignEnd="@+id/map"
android:layout_alignRight="@+id/map"
android:layout_alignLeft="@+id/map"
android:layout_alignStart="@+id/map"
android:src="@android:color/transparent"/>
</RelativeLayout>
.....
.....
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
码:
transImg.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN: …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的菜单项实现自定义布局,并且通过许多解决方案,每当我尝试在为我的菜单项指定的布局中获取 TextView 时,我都会收到空指针异常,actionLayout因为 getActionView 返回 null。
主页菜单:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_notifications"
android:title=""
app:showAsAction="always"
android:visible="true"
android:icon="@drawable/ic_notifications_black_24dp"
android:orderInCategory="3"
android:actionLayout="@layout/counter_action_bar_notification_icon"
/>
<!--android:icon="@drawable/ic_notifications_black_24dp"-->
<!--android:actionLayout="@layout/bage_layout"-->
</menu>
Run Code Online (Sandbox Code Playgroud)
counter_action_bar_notification_icon
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center"
android:clickable="true"
style="@android:style/Widget.ActionButton">
<ImageView
android:id="@+id/hotlist_bell"
android:src="@drawable/ic_notifications_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_margin="0dp"
android:contentDescription="bell"
/>
<TextView
android:id="@+id/hotlist_hot"
android:layout_width="wrap_content"
android:minWidth="17sp"
android:textSize="12sp"
android:textColor="#ffffffff"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@null"
android:layout_alignTop="@id/hotlist_bell"
android:layout_alignRight="@id/hotlist_bell"
android:layout_marginRight="0dp"
android:layout_marginTop="3dp"
android:paddingBottom="1dp"
android:paddingRight="4dp"
android:paddingLeft="4dp"
android:background="@drawable/bage_circle"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
主要活动:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.home_menu, menu); …Run Code Online (Sandbox Code Playgroud) 我跟随Github Link使用ReteroFit和RxJava来使用API,但是在我的接口类中将类型从Call更改为Observer时,我收到一条错误消息.
类型'java.util.Observable'没有类型参数
ApiClient:
public class ApiClient {
public static final String BASE_URL = "*********";
private static Retrofit retrofit = null;
public static Retrofit getClient() {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.build();
if (retrofit==null) {
Gson gson = new GsonBuilder()
.setLenient()
.create();
retrofit = new Retrofit.Builder()
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
}
return retrofit;
}
}
Run Code Online (Sandbox Code Playgroud)
ApiInterface
public interface ApiInterface {
@FormUrlEncoded
@POST("user/get_user")
Observable<UserResponse> getUsers(@Field("email") String email, @Field("password") String password);
}
Run Code Online (Sandbox Code Playgroud)
UserResponse:
public …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我试图使用Retrofit 2和从我的网络服务器获取数据RxJava2.但是当我订阅我的API接口方法时,我得到错误
Cannot Resolve method 'subscribe(anonymous org.reactivestreams.Subscriber<*Model Name*>
Run Code Online (Sandbox Code Playgroud)
API客户端:
public class ApiClient {
public static final String BASE_URL = "*********";
private static Retrofit retrofit = null;
public static Retrofit getClient() {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.build();
if (retrofit==null) {
Gson gson = new GsonBuilder()
.setLenient()
.create();
retrofit = new Retrofit.Builder()
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
}
return retrofit;
}
}
Run Code Online (Sandbox Code Playgroud)
ApiInterface
public interface ApiInterface {
@FormUrlEncoded
@POST("user/get_user")
Observable<UserResponse> getUsers(@Field("email") String …Run Code Online (Sandbox Code Playgroud) 我有一个optionMenu在我MainActivity膨胀的内部onCreateOptionsMenu,MainActivity并且有一些碎片在内部膨胀,MainActivity它们有自己的Toolbars。但问题是在碎片内部OptionMenu也是可见Toolbars的。我不希望片段具有OptionMenufor Fragments 工具栏
android ×7
retrofit2 ×2
rx-java2 ×2
charts ×1
fragment ×1
google-maps ×1
menuitem ×1
uipickerview ×1