我得到了这个对象的ArrayList,我需要将它设置为我的spinner的适配器,如下所示:
ArrayList<Contact> contactlist= new ArrayList<Contact>();
contactlist.add("Gabe");
contactlist.add("Mark");
contactlist.add("Bill");
contactlist.add("Steve");
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, contactlist);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
contactsSpinner.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
这是我的Contact对象的一个例子,它只有两个变量,Name和ID
Contact contact = new Contact();
contact.setName("Gabe")
contact.setID("14575")
Run Code Online (Sandbox Code Playgroud)
我需要让微调器显示来自ArrayList的联系人姓名,因为它显示了内存中的联系地址,选中后,我需要返回联系人ID,以执行其他操作.我怎样才能做到这一点?
我是可观察的概念的新手,需要一些转换帮助.
我有一个服务Observable<Response>从Http请求返回一个,但我需要转换它做一个在connect方法内部Observable<PriceTag>使用它DataSource.
反正有没有这样做?
这是我服务的方法:
getPriceTags(): Observable<Response> {
// Set the request headers
const headers = new Headers({ 'Content-Type': 'application/json' });
// Returns the request observable
return this.http.post(Constants.WEBSERVICE_ADDRESS + "/priceTag", null, {headers: headers});
}
Run Code Online (Sandbox Code Playgroud)
这是DataSource类,我需要将其作为以下内容返回Observable<PriceTag>:
export class PriceTagDataSource extends DataSource<PriceTag> {
constructor (private priceTagService: PriceTagService) {
super();
}
connect(): Observable<PriceTag> {
// Here I retrieve the Observable<Response> from my service
const respObs = this.priceTagService.getPriceTags();
// Now I need to return a Observable<PriceTag>
} …Run Code Online (Sandbox Code Playgroud) 有没有办法知道我的改装电话何时完成了它的职责?我知道什么时候收到所有数据,所以代码可以继续,比如开始另一个活动或者使用第一次调用的数据做一秒钟?
Ps.:我正在使用异步请求(.enqueue).
编辑:
getContact(){
//Get a contact List from the server
Call<List<ModelContact>> callM = contactInterface.createRContact(listContact);
callM.enqueue(new Callback<List<ModelContact>>() {
@Override
public void onResponse(Response<List<ModelContact>> response, Retrofit retrofit) {
// Fetch the List from Response and save it on the local database
}
@Override
public void onFailure(Throwable t) {
Log.i("TAG", "Error: " + t.getMessage());
}
});
//Gets a object containing some configurations
Call<Configs> callC = contactInterface.getConfigs(Configs);
callC.enqueue(new Callback<Configs>() {
@Override
public void onResponse(Response<Configs> response, Retrofit retrofit) {
// Fetch the Configs object and …Run Code Online (Sandbox Code Playgroud) 我想知道如何做一个下拉按钮/菜单,就像我们可以在Google的设计规格和下面的图片中看到的那样,所以列表在按钮下方展开.我是否需要为它设置自定义布局而不是R.layout.support_simple_spinner_dropdown_item?
今天早上我的mySQL在我的系统上自动从5.7到8.0.11更新.
在此之后,我无法看到任何数据库或在phpMyAdmin上运行任何命令.我尝试做的每件事都会导致涉及mysql.infoschema表格的一些错误.
我得到的大多数错误都是这样的: #1449 - The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
我已经搜索了错误并尝试运行命令来创建用户GRANT ALL ON *.* TO 'someuser'@'%' IDENTIFIED BY 'complex-password';
FLUSH PRIVILEGES;,如此答案中所示.但我不断收到语法错误.
在搜索涉及版本5.7和8.0.11的突发问题后,我在此站点中看到系统表已移至InnoDB.
MySQL的第一个存储引擎 - MyISAM,到目前为止在MySQL中可用.MySQL 5.7仍然使用MyISAM作为MySQL模式中的MySQL权限表,但在MySQL中它们被移动到InnoDB.
我甚至尝试了8.0.11的全新安装,所以我可以导入我的数据库,但是当我尝试以root身份登录时,我得到了相同的#1449错误.
PS.我正在使用Fedora 28.
Angular Material 2是否有一个选择器来自定义md-item-templateAngularJS的Angular Material等自动完成选项?我在材料2 的文档中找不到任何内容
来自docs的 AngularJS示例:
<md-autocomplete
<md-item-template>
<span class="item-title">
<md-icon md-svg-icon="img/icons/octicon-repo.svg"></md-icon>
<span> {{item.name}} </span>
</span>
<span class="item-metadata">
<span class="item-metastat">
<strong>{{item.watchers}}</strong> watchers
</span>
<span class="item-metastat">
<strong>{{item.forks}}</strong> forks
</span>
</span>
</md-item-template>
</md-autocomplete>
Run Code Online (Sandbox Code Playgroud)
我创建了一种方法来检查我的应用程序是否能够使用 OkHttp 连接到我的服务器。
这是我的测试课:
public class NetworkTest {
static boolean resultWeb = false;
public static boolean pingTestWeb() {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://www.google.com")//My server address will go here
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e) {
resultWeb = false;
Log.i("Error","Failed to connect: "+e.getMessage());
}
@Override
public void onResponse(Response response) throws IOException {
Log.i("Success","Success: "+response.code());
if (response.code() == 200) {
resulWeb = true;
}
}
});
return resultWeb;
}
Run Code Online (Sandbox Code Playgroud)
这是我在 OnCreate() …
我想在输入时使用正则表达式来格式化输入中的数字.
我的问题是:由于我使用组来格式化数字,它只在字符串与正则表达式匹配时才格式化.这是一个例子:
完整的数字是:12312312312| 格式化看起来像:123.123.123-12.
如果我输入1231231例如,它不会123.123.1像我期望的那样格式化,只有当我键入整个数字时.
这是我的功能:
format(value){
// This function returns the formatted string on user input
return value.replace(/(\d{3})(\d{3})(\d{3})(\d+)/, "\$1.\$2.\$3-\$4");
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让其余的组选项?
android ×4
angular ×2
typescript ×2
api ×1
autocomplete ×1
button ×1
connection ×1
fedora ×1
mysql ×1
observable ×1
okhttp ×1
php ×1
phpmyadmin ×1
ping ×1
regex ×1
replace ×1
retrofit ×1
retrofit2 ×1
rxjs ×1
spinner ×1
timeout ×1
web-services ×1