how to lock result on search in android.i use list view in search
and use in app billing purchase.i wish lock search result when position
item big 10 . i lock list view in search when user just scroll but when user search can red item i wish limit user to read items when user search . How can restricted user when still plans to upgrade the original version can not read more than ten search results that position. Because when the user has not contributed to the program can also be
read more than ten search results Koch position but if he does without something in the search box will only scroll down Items that their position can not be read how to walk more than ten search results for the user to upgrade to the original building plans.
my class search
package ir.GiyaHan.giyahan;
import ir.GiyaHan.database.DBAdapter;
import ir.GiyaHan.database.Dastan;
import java.util.List;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.Toast;
public class SerchDemo extends ListActivity {
DBAdapter db;
List<Dastan> dastanha;
ListView lst;
EditText et;
RadioButton rd_name;
public static final String SKU_PREMIUM = "ML";
public boolean mIsPremium = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
db = new DBAdapter(getBaseContext());
db.open();
lst = getListView();
et = (EditText) findViewById(R.id.search_et);
rd_name = (RadioButton) findViewById(R.id.search_rdName);
//final RadioButton rd_nevis = (RadioButton)
findViewById(R.id.search_rdNevisande);
et.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int
arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void after Text Changed(Editable arg0) {
// TO DO Auto-generated method stub
if(rd_name.is Checked()){
dastanha = db.find Contacts(e t.get Text().to String(),
DB Adapter.KEY_ONVAN);
}
Refresh Display();
}
});
}
protected void on List Item Click(List View l, View v, int position,
long id) {
// TO DO Auto-generated method stub
super.on List ItemClick(l, v, position, id);
Dastan dastan = dastanha.get(position);
if(position>10 && m Is Premium != true){
Toast.make Text(get Application Context(), "ارتقا دهید",
Toast.LENGTH_SHORT). show();
}else if(position<10 && m Is Premium != true){
Intent next = new Intent(this, Show Dastan.class);
next.put Extra("thisdastan", dastan);
start Activity For Result(next, position);
}
}
public void Refresh Display(){
Log.i(DB Adapter.TAG, dastanha.size()+ "=tedad dastanha");
Array Adapter<Dastan> adapter = new Dastan Adapter(this,
dastanha);
set List Adapter(adapter);
}
@Override
protected void on Resume() {
// TO DO Auto-generated method stub
super.on Resume();
if(rd_name.is Checked()){
dastanha = db.find Contact s(e t.get Text(). to String(),
DB Adapter.KEY_ONVAN);
}
Refresh Display();
}
}
`
layout xml
<RelativeLayout
xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_back"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="ir.GiyaHan.giyahan.Search" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/radioGroup1" >
</ListView>
<EditText
android:id="@+id/search_et"
android:layout_width="wrap_content"
android:maxLines="10"
android:layout_height="wrap_content"
android:layout_alignLeft="@android:id/list"
android:layout_alignParentTop="true"
android:layout_alignRight="@android:id/list"
android:ems="10"
android:hint="search" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/search_et"
android:layout_centerHorizontal="true"
android:gravity="right" >
<RadioButton
android:id="@+id/search_rd Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="na" />
</RadioGroup>
</RelativeLayout>`
Aucun commentaire:
Enregistrer un commentaire