アプリの Android バージョンを開発しており、この図に示されているデザインを複製しようとしています。 http://s1298.photobucket.com/user/Mitch_Thornton/media/Screenshot2013-06-03at50428PM_zps3d9b6acc.png.html?sort=3&o=0
私が保存したデータは、Web サイトから供給されます。これまでのところ、オートコンプリートがデータを正しく検索するように成功しました。私の問題はフォーマットです。テキストの特定の部分を制御およびスタイル設定できるようにしたいと考えています。具体的にはパーセンテージ。パーセンテージが 75% を超えると緑になり、75% を下回ると赤または黄色になります。
問題は、私は 1 本の長い紐を扱っているので、特定のピースを個別にスタイリングできないことです。
スペースとラインを追加することで貧弱なスタイルのスタイリングを得ることができましたが、特別なことは何もありません .... 06-03at51100PM_zps6859e634.png.html?sort=3&o=1
私は Android を初めて使用するので、これまでに得たものはチュートリアルや独学から得たものです。私はあなたの助けに本当に感謝しています
検索_ページ:
public class Search_Page extends Activity implements TextWatcher {
AutoCompleteTextView myAutoComplete;
// PROBLEM: This initializes and defines the string array...It also says how
// big the string array can be
// So this limits how many items I can grab from Parse and fill in the
// array....
// I can only fill/replace as many items/elements that are defined right
// here
String item[] = { "Jack Daniels", "Captain Morgan", "Corona", "Dubra",
"KeyStone Light", "Burnettes", "Budweiser", "Bud Light",
"Smirnoff", "Grey Goose", "Smirnoff", "Mike's Hard Lemonade",
"Poland Springs", "Yukon Jack", "Magic Hat",
"Captain Morgan Black", "Absolut", "Absolut Raspberry",
"Absolut Mandarin", "Absolut Peppar", "Absolut Citron",
"Absolut Vanilla", "Wild Turkey" };
public String selection = "";
ParseObject dealsObject;
int n = 0;
int p = 0;
String mydate;
String objectId;
private String[] obj = { "Jack Daniels", "Captain Morgan", "Corona",
"Dubra", "KeyStone Light", "Burnettes", "Budweiser", "Bud Light",
"Smirnoff", "Grey Goose", "Smirnoff", "Mike's Hard Lemonade",
"Poland Springs", "Yukon Jack", "Magic Hat",
"Captain Morgan Black", "Absolut", "Absolut Raspberry",
"Absolut Mandarin", "Absolut Peppar", "Absolut Citron",
"Absolut Vanilla", "Wild Turkey" };
private int[] percent = { 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4,
5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2,
3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_page);
Parse.initialize(this, "vUz23Z6zdIL1jbxbVWeLpsSdu1ClTu3YiG30zTWY",
"4BTyoq1QQKows8qVJV7lvU3ZokSRrLFyOCPzffwJ");
myAutoComplete = (AutoCompleteTextView) findViewById(R.id.myautocomplete1);
// Using this Parsequery...I can grab/locate the objects from the Parse
// list...Here I grabbed the objects that have Burnettes and the price
// of it
// Eventually I may need to set a limit on how many results I will get
// from the for loop....So far I think it is limited to 100 by default
ParseQuery query = new ParseQuery("Deals");
// query.whereEqualTo("Brand", "Burnettes");
query.findInBackground(new FindCallback() {
@Override
public void done(List<ParseObject> objects, ParseException e) {
if (e == null) {
Log.d("Brand", "Retrieved " + objects.size() + " Brands");
for (ParseObject dealsObject : objects) {
// use dealsObject.get('columnName') to access the
// properties of the Deals object
SimpleDateFormat format = new SimpleDateFormat(
"MMM dd, yyyy");
String date = format.format((dealsObject.getCreatedAt()));
objectId = dealsObject.getObjectId();
// Grabs the position of the object in Parse and spits
// out the Brand, price.
// This is then put into the autocomplete dropdown
percent[n] = dealsObject.getInt("Percentage");
item[n] = dealsObject.getString("Brand") + " "
+ dealsObject.getString("Size") + " $"
+ dealsObject.getString("Price")
+ " "
+ dealsObject.getInt("Percentage") + "%" + "\n"
+ date;
obj[n] = objectId;
n++;
}
} else {
Log.d("Brand", "Error: " + e.getMessage());
}
}
});
myAutoComplete.addTextChangedListener(this);
myAutoComplete.setAdapter(new ArrayAdapter<String>(this,
R.layout.my_custom_dropdown, item));
// When the user selects an element from the dropdown, it will
// automatically
// go to the DealPage
myAutoComplete.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
while (true) {
if (arg0.getItemAtPosition(arg2).equals(item[p])) {
break;
}
p++;
}
selection = (String) arg0.getItemAtPosition(arg2);
Log.d("Before", selection);
Intent myIntent = new Intent("com.alpha.dealtap.DEALPAGE");
myIntent.putExtra("Stuff", selection);
myIntent.putExtra("ObjectId", obj[p]);
myIntent.putExtra("Percent", percent[p]);
startActivity(myIntent);
}
});
Log.d("After", selection);
Button deal = (Button) findViewById(R.id.b2);
Button map = (Button) findViewById(R.id.map);
deal.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
startActivity(new Intent("com.alpha.dealtap.DEALPAGE"));
}
});
Intent myIntent = new Intent(Search_Page.this, DealPage.class);
map.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.alpha.dealtap.MAP"));
}
});
}
@Override
protected void onPause() {
super.onPause();
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@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
}
}
Search_Page.xml:
<?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:background="#FFFFFF" >
<Button
android:id="@+id/map"
style="@style/ButtonText"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/b2"
android:background="@drawable/yellow_button"
android:text="Map"
android:textSize="20sp" />
<Button
android:id="@+id/b2"
style="@style/ButtonText"
android:layout_width="160dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/yellow_button"
android:text="Deal"
android:textSize="20sp" />
<AutoCompleteTextView
android:id="@+id/myautocomplete1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/map"
android:completionThreshold="1"
android:ems="10"
android:hint="Search for deals" >
<requestFocus />
</AutoCompleteTextView>
</RelativeLayout>
my_custom_dropdown.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textColor="@color/black"
android:textSize="17sp" />