我只能从文档中运行hello world示例(GithubService).
问题是当我运行我的代码时,我得到以下错误,里面 onFailure()
使用JsonReader.setLenient(true)在第1行第1列路径$接受格式错误的JSON
我的API采用POST参数值,因此不需要将它们编码为JSON,但它确实以JSON形式返回响应.
对于响应,我得到了使用工具生成的ApiResponse类.
我的界面:
public interface ApiService {
@POST("/")
Call<ApiResponse> request(@Body HashMap<String, String> parameters);
}
Run Code Online (Sandbox Code Playgroud)
以下是我使用该服务的方式:
HashMap<String, String> parameters = new HashMap<>();
parameters.put("api_key", "xxxxxxxxx");
parameters.put("app_id", "xxxxxxxxxxx");
Call<ApiResponse> call = client.request(parameters);
call.enqueue(new Callback<ApiResponse>() {
@Override
public void onResponse(Response<ApiResponse> response) {
Log.d(LOG_TAG, "message = " + response.message());
if(response.isSuccess()){
Log.d(LOG_TAG, "-----isSuccess----");
}else{
Log.d(LOG_TAG, "-----isFalse-----");
}
}
@Override
public void onFailure(Throwable t) {
Log.d(LOG_TAG, "----onFailure------");
Log.e(LOG_TAG, t.getMessage());
Log.d(LOG_TAG, "----onFailure------");
}
});
Run Code Online (Sandbox Code Playgroud) 我正在寻找一种像网络术语中的选取框一样滚动文本的有效方法。
我设法使用我在网上找到的一段代码来实现这一点:
private int xPos = 0, YPos = 0;
private void Form1_Load(object sender, EventArgs e)
{
//link label
lblText.Text = "Hello this is marquee text";
xPos = lblText.Location.X;
YPos = lblText.Location.Y;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (xPos == 0)
{
this.lblText.Location = new System.Drawing.Point(this.Width, YPos);
xPos = this.Width;
}
else
{
this.lblText.Location = new System.Drawing.Point(xPos, YPos);
xPos -= 2;
}
}
Run Code Online (Sandbox Code Playgroud)
代码非常简单,它使用了一个计时器滴答事件。
它最初运行良好,但在滚动 3 或 4 次后,它不再出现。
有什么我可以调整以使滚动无限的吗?