所以我试图对一个简单的arrayadapter listview进行排序.这是我尝试过的:
ListView lv;
String[] months = {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
ArrayAdapter<String> adapter;
ArrayList<String> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv = (ListView) findViewById(R.id.listView1);
lv.setFastScrollEnabled(true);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, months);
lv.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO …
Run Code Online (Sandbox Code Playgroud) 我认为这是一个基本问题,但我在他们的网站上找不到这个,或者如果我错了就纠正我.我想问一下phonegap应用程序是否需要连接到互联网才能使用?我需要了解并了解这个.由于我在两个选项之间徘徊,无论是使用本机代码还是使用phonegap.谢谢
你知道如何在文本框中限制用户输入,这个文本框只接受整数吗?顺便说一句,我正在为Windows 8开发.我尝试过从SO和Google搜索的内容,但是它没有用,
我想开发一个只使用离线数据库的android英文字典应用程序.通过这种方式,我的意思是说它不必被重定向到像WordWeb之类的在线词典.有人知道我该怎么做来存储我的话吗?我正在考虑使用SQLite,因为它是移动的.但如果这里的任何人已经做了或做了我想做的事情,你能给我一些专家建议吗?
所以我正在玩字符串操作.我用连字符替换了空白字符.现在我想组合替换空格字符并从字符串中删除撇号.我怎样才能做到这一点?
这是我到目前为止所尝试的:
String str = "Please Don't Ask Me";
String newStr = str.replaceAll("\\s+","-");
System.out.println("New string is " + newStr);
Run Code Online (Sandbox Code Playgroud)
输出是:
Please-Don't-Ask-Me
Run Code Online (Sandbox Code Playgroud)
但我希望输出为:
Please-Dont-Ask-Me
Run Code Online (Sandbox Code Playgroud)
但我不能去除撇号.有任何想法吗?非常感谢帮助.谢谢.
我一直在做的是关于customadapter.现在我想从列表视图中获取所选项目,但它的适配器是自定义的.在我的列表视图中,我有一个图像,标题和标题,我想获得所选项目,在我的情况下只是标题.我怎么做?
这是我到目前为止所尝试的:
@Override
public void onItemClick(AdapterView<?> parent, View v, int pos, long id) {
String strHouseName = "house_name";
String strHousePrice = "house_price";
//String selectedFromList =(String) (lv.getItemAtPosition(pos));
Intent i;
switch(pos){
case 0:
i = new Intent(this, ViewHouse.class);
i.putExtra(strHouseName, "5 Dina Retreat, Carrum Downs");
i.putExtra(strHousePrice, "$300,000.00");
startActivity(i);
break;
case 1:
i = new Intent(this, ViewHouse.class);
i.putExtra(strHouseName, "Lot 941 Cob Terrace, Clyde North");
i.putExtra(strHousePrice, "$800,000.00");
startActivity(i);
break;
case 2:
i = new Intent(this, ViewHouse.class);
i.putExtra(strHouseName, "Lot 932 Ventasso Street, Clyde");
i.putExtra(strHousePrice, "$1,000,000.00");
startActivity(i); …
Run Code Online (Sandbox Code Playgroud) 各位大家好,我想获得当前的约会对象.
这是我试过的:
<?php
$transdate = date('m-d-Y', time());
echo $transdate;
$month = date('m', strtotime($transdate));
if($month == "12"){
echo "<br />December is the month :)";
} else {
echo "<br /> The month is probably not December";
}
?>
Run Code Online (Sandbox Code Playgroud)
但结果是错误的,它应该显示12月是月份:0
有任何想法吗?谢谢.
我正在尝试使用cursoradapter过滤我的listview.这是我到目前为止所尝试的:
CustomAdapter adapter;
Cursor cursor;
etSearch.addTextChangedListener(new TextWatcher (){
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence cs, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
adapter.getFilter().filter(cs.toString());
}
});
cursor = dbHelper.getAllItemInventoryListings();
adapter = new CustomAdapter(this, cursor);
lv.setAdapter(adapter);
lv.setTextFilterEnabled(true);
adapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
String strItemCode = constraint.toString();
return dbHelper.getAllItemInventoryListings(strItemCode); …
Run Code Online (Sandbox Code Playgroud) 我有一个在NavigationDrawer中有多个片段的应用程序.
以下是我的代码:
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// if nav drawer is opened, hide the action items
boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
menu.findItem(R.id.action_search).setVisible(!drawerOpen);
return super.onPrepareOptionsMenu(menu);
}
/**
* Diplaying fragment view for selected nav drawer list item
* */
private void displayView(int position) {
// update the main content by replacing fragments
fragment = null;
switch (position) {
case 0:
fragment = new HomeFragment();
break;
case 1:
fragment = new GalleryFragment();
break;
case 2:
fragment = new ContactFragment();
break;
default: …
Run Code Online (Sandbox Code Playgroud) 我希望在用户结束输入后获得edittext的值.因此默认情况下,edittext为空.它没有任何价值.用户输入一个值后,它应该得到它.
这就是我尝试过的:
etQuantity.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
Log.d("Quantity", s_quantity);
int i_quantity = Integer.parseInt(s_quantity);
int i_grossAmount = i_quantity * i_sellingPrice;
etGrossAmount.setText(String.valueOf(i_grossAmount));
Log.d("Gross Amount", "" + String.valueOf(i_grossAmount));
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
});
Run Code Online (Sandbox Code Playgroud)
但它没有得到我输入的正确值.有任何想法吗?非常感谢帮助.谢谢.