我正在尝试从 Firebase 将数据加载到 RecycleView。但我得到转换错误。
com.google.firebase.database.DatabaseException: Can't convert object of type java.util.ArrayList to type uk.co.stableweb.kithunugee.model.Hymn
at com.google.android.gms.internal.zzaix.zzd(Unknown Source)
at com.google.android.gms.internal.zzaix.zzb(Unknown Source)
at com.google.android.gms.internal.zzaix.zza(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.firebase.ui.database.FirebaseRecyclerAdapter.parseSnapshot(FirebaseRecyclerAdapter.java:147)
at com.firebase.ui.database.FirebaseRecyclerAdapter.getItem(FirebaseRecyclerAdapter.java:136)
at com.firebase.ui.database.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:176)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5471)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5504)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4741)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1390)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2625)
at android.view.View.measure(View.java:18850)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5956)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:668)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1192)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:733)
at android.view.View.measure(View.java:18850)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1075)
at android.view.View.measure(View.java:18850)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用画布绘制文本.我到处检查过,但这些例子相当复杂,我可以在画布上绘制文字,但它不像这张照片那样显示.

我发现这个代码并且它正常工作,我只需要像上面的图像一样写.
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setTextSize(30);
paint.setAntiAlias(true);
canvas.drawText("There are 137 days, 9 hours 4 minutes and 36 seconds", 150,150, paint);
Run Code Online (Sandbox Code Playgroud) 我试图通过使用该setText()方法更新JLabel ,但我无法重绘JLabel.我必须使用这种repaint()方法吗?
这是代码的一部分,我没有得到任何错误,但它没有更新JLabel.
public void actionPerformed(ActionEvent e) {
fc = new JFileChooser();
if(e.getSource() == addButton) {
int returnVal = fc.showOpenDialog(Main.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
filesList = fc.getSelectedFiles();
setFilesList(filesList);
StringBuilder logString = new StringBuilder();
logString.append("Files to Convert " + "\n");
for(int i = 0; i < getFiles().length; i++) {
logString.append(filesList[i].getAbsolutePath());
}
//JLabel log = new JLabel(); created above.
log.setText(logString.toString());
} else {
//log.append("Open command cancelled by user." + newline);
}
//log.setCaretPosition(log.getDocument().getLength());
}
}
Run Code Online (Sandbox Code Playgroud) 我使用Android Studio使用New - > Activity - > Basic Activity创建基本活动.但活动背景颜色为黑色.我知道这是为了减少电池消耗.但有没有办法将其改为白色,而不改变风格.
我试图更改根布局的背景颜色,但之后它不会显示编辑文本字段的提示文本.因为它的颜色是白色的.
然后我尝试将主题从Material更改为Material Lite,然后当我在设备中运行应用程序时,它不会显示更改.
这是AndroidManifest.xml中的活动声明
<activity
android:name=".SearchBus"
android:label="@string/title_activity_search_bus"
android:parentActivityName=".MapsActivity"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="uk.co.stableweb.iroute.MapsActivity" />
</activity>
Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel 数据库:分页来显示刀片模板中的链接。我可以查看列中的数据,但不能查看链接。
这是我用来传递数据以查看的控制器函数。
public function showProducts(){
$products = DB::table('products')->orderBy('created_at')->simplePaginate(9);
return view('products', ['products' => $products]);
}
Run Code Online (Sandbox Code Playgroud)
这是显示链接的视图部分。
<div class="row text-center">
<div class="col-lg-12">
<ul class="pagination">
{{ $products->links() }}
</ul>
</div>
</div>
<!-- /.row -->
Run Code Online (Sandbox Code Playgroud)
但是我看不到任何链接。有没有办法解决这个问题?
我正在使用android中的ProgressBar类,但是我无法在5秒内完成它并加载应用程序.一切正常但进度条没有进展.这是代码.
public class StartPoint extends Activity{
ProgressBar progressBar;
private int progressBarStatus = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
progressBar = (ProgressBar)findViewById(R.id.progressBar1);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
while(progressBarStatus < 5000){
progressBar.setProgress(progressBarStatus);
progressBarStatus += 1000;
}
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openMainList = new Intent(StartPoint.this, in.isuru.caf.MainList.class);
startActivity(openMainList);
}
}
};
timer.start();
}
protected void onPause(){
super.onPause();
finish();
}
}
Run Code Online (Sandbox Code Playgroud)
这是布局文件splash.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用java servlet构建注册系统.并将数据插入mySQL数据库.但是我收到了语法错误.我刚读完Wiley mySQL和Java开发人员指南.
而且我对servlet编程有点新意,所以如果有简单的方法可以做我做的事情,请告诉我.
package com.app.base;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.app.pojo.*;
public class RegisterServlet extends HttpServlet{
MySqlDB mysql;
@Override
public void init() throws ServletException {
// TODO Auto-generated method stub
mysql = new MySqlDB();
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter out = null;
//Connection connection = null;
//Statement statement;
//ResultSet rs;
resp.setContentType("text/html");
out = …Run Code Online (Sandbox Code Playgroud) 我正在尝试从Firebase子节点获取数据.但它抛出Can't convert object of type java.lang.String to type uk.co.stableweb.geethika.model.DailyVerse异常.
这是我的Firebase数据库的结构.
这是代码.我正在使用Android Firebase新文档.
mRef = FirebaseDatabase.getInstance().getReference().child("daily_verse");
mRef.keepSynced(true);
ChildEventListener childEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) {
Log.d("Child Event,Verse", dataSnapshot.getKey());
dailyVerse = dataSnapshot.getValue(DailyVerse.class);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) {
Log.d("Child Event,Verse", "onChildChanged:" + dataSnapshot.getKey());
dailyVerse = dataSnapshot.getValue(DailyVerse.class);
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) {
}
@Override
public void onCancelled(DatabaseError databaseError) { …Run Code Online (Sandbox Code Playgroud)