mercredi 15 juin 2016

how can filter this list? [on hold]

hi i have a problem i when filter the list with edittext, the filter find what i want but when i click on the item the filter open another item.

public class Garrote extends Activity {

//lista armi garrote

//this section is for d&d 3.5

// Thank you for all your assistance

String[] listaarmigarrote = new String[]{"Bolas","Chain","Chain, Spiked","Cord","Flail, Dire","Garrote Ring","Locking Mechanism","Rope","Sling","Steel Cable","Whip","Wire"};


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_garrote);

    final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_expandable_list_item_1, listaarmigarrote);
    final ListView listaarmigarrote = (ListView) findViewById(R.id.listgarotte);

    listaarmigarrote.setAdapter(adapter);


    listaarmigarrote.setFilterTouchesWhenObscured(true);
    listaarmigarrote.setTextFilterEnabled(true);



    final EditText search=(EditText)findViewById(R.id.search);
    search.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

//after this when use the app normaly workk all okay

    listaarmigarrote.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch ( position )
                {
                    case 0: Intent Bolas=new Intent(getApplicationContext(),dettagli_armi.class);
                        Bolas.putExtra("costo","5 gp");
                        Bolas.putExtra("dannis","1D3");
                        Bolas.putExtra("dannim","1D4");
                        Bolas.putExtra("crit","-");
                        Bolas.putExtra("rangeinc","-");
                        Bolas.putExtra("weight","2 lb.");
                        Bolas.putExtra("type","Exotic");
                        Bolas.putExtra("dettagli","Strangle Bonus=1.n" +
                                " Two-handed.n" +
                                "n" +
                                " A bolas is a set of three weighted balls connected by leather cords.n" +
                                " To attack, you whirl the bolas in a circle over your head and then fling it at a target.n" +
                                " The bolas connect with your opponent with a successful ranged touch attack.n" +
                                " Disregard any armor, shield, or natural armor bonus of the target.n" +
                                "n" +
                                " A character struck by bolas must make a Reflex save (with a DC equal to the attack roll of the bolas's wielder).n" +
                                " If the saving throw fails, the target takes subdual damage and is considered pinned.n" +
                                " (See "Grapple" in Chapter 8: Combat of the Player's Handbook for more information).n" +
                                " The bolas can pin only a Tiny, Small, or Medium-size target.n" +
                                " To escape the bolas, the pinned character must either break out (Strength check, DC 20), wriggle free (Escape Artist check, DC 20), or cut (or be cut) loose (5 hp and only slashing weapons do damage).n" +
                                "n" +
                                " Regardless of the method, escaping is a full-round action.n" +
                                " (Remember that a target can use the take 10 or take 20 action to escape if the situation allows).n" +
                                " If the saving throw succeeds, the target suffers normal damage but is not pinned.n" +
                                " Bolas can also be used as a garrote.n");
                        Bolas.putExtra("Source","Dragon #355");
                        startActivity(Bolas);
                        break;
                    case 1: Intent Chain=new Intent(getApplicationContext(),dettagli_armi.class);
                        Chain.putExtra("costo","15 gp");
                        Chain.putExtra("dannis","1D4");
                        Chain.putExtra("dannim","1D6");
                        Chain.putExtra("crit","-");
                        Chain.putExtra("rangeinc","-");
                        Chain.putExtra("weight","2 lb.");
                        Chain.putExtra("type","-");
                        Chain.putExtra("dettagli","Strangle Bonus=2.n" +
                                " Two-handed.n" +
                                "n" +
                                " A chain has reach.n" +
                                "n" +
                                " You can strike opponents 10 feet away with it.n" +
                                " In addition, unlike other weapons with reach, you can use it against an adjacent foe.n" +
                                "n" +
                                " Because the chain can wrap around an enemy's leg or other limb, you can make trip attacks with it.n" +
                                " If you are tripped during your own trip attempt, you can drop the chain to avoid being tripped.n");
                        Chain.putExtra("Source","Dragon #355");
                        startActivity(Chain);
                        break;
                    case 2:  Intent ChainSpiked=new Intent(getApplicationContext(),dettagli_armi.class);
                        ChainSpiked.putExtra("costo","25 gp");
                        ChainSpiked.putExtra("dannis","1D6");
                        ChainSpiked.putExtra("dannim","1D8");
                        ChainSpiked.putExtra("crit","19-20/x2");
                        ChainSpiked.putExtra("rangeinc","-");
                        ChainSpiked.putExtra("weight","10 lb.");
                        ChainSpiked.putExtra("type","Exotic");
                        ChainSpiked.putExtra("dettagli","Strangle Bonus=2.n" +
                                " Two-handed.n" +
                                "n" +
                                " A spiked chain has reach.n" +
                                " You can strike opponents 10 feet away with it.n" +
                                " In addition, unlike other weapons with reach, you can use it against an adjacent foe.n" +
                                "n" +
                                " Because the chain can wrap around an enemy's leg or other limb, you can make trip attacks with it.n" +
                                " If you are tripped during your own trip attempt, you can drop the chain to avoid being tripped.n" +
                                "n" +
                                " When using a spiked chain, you get a +2 bonus on your opposed attack roll when attempting to disarm an opponent (including the roll to avoid being disarmed if you fail to disarm your opponent).n" +
                                " You can use the Weapon Finesse feat to apply your Dexterity modifier instead of your Strength modifier to attack rolls with a spiked chain.n");
                        ChainSpiked.putExtra("Source","Dragon #355");
                        startActivity(ChainSpiked);
                        break;
                    case 3: Intent Cord=new Intent(getApplicationContext(),dettagli_armi.class);
                        Cord.putExtra("costo","1 sp");
                        Cord.putExtra("dannis","1D4");
                        Cord.putExtra("dannim","1D6");
                        Cord.putExtra("crit","-");
                        Cord.putExtra("rangeinc","-");
                        Cord.putExtra("weight","1/10 lb.");
                        Cord.putExtra("type","-");
                        Cord.putExtra("dettagli","Strangle Bonus=1.n" +
                                " Two-handed.n" +
                                "n" +
                                " Cord has hardness 0, 2 hit points, and a break DC of 20.n" +
                                " Price is for 5 ft.");
                        Cord.putExtra("Source","Dragon #355");
                        startActivity(Cord);
                        break;
                    case 4: Intent Flaildire=new Intent(getApplicationContext(),dettagli_armi.class);
                        Flaildire.putExtra("costo","90 gp");
                        Flaildire.putExtra("dannis","1D4");
                        Flaildire.putExtra("dannim","1D6");
                        Flaildire.putExtra("crit","19-20/x2");
                        Flaildire.putExtra("rangeinc","-");
                        Flaildire.putExtra("weight","10 lb.");
                        Flaildire.putExtra("type","Exotic");
                        Flaildire.putExtra("dettagli","Strangle Bonus=2.n" +
                                " Two-handed.n" +
                                "n" +
                                " A dire flail is a double weapon.n" +
                                " You can fight with it as if fighting with two weapons, but if you do, you incur all the normal attack penalties associated with fighting with two weapons, as if you were using a one-handed weapon and a light weapon.n" +
                                " A creature using a double weapon in one hand, such as an ogre using a dire flail, can't use it as a double weapon.n" +
                                "n" +
                                " With a dire flail, you get a +2 bonus on your opposed attack roll when attempting to disarm an enemy (including the opposed attack roll to avoid being disarmed if you fail to disarm your enemy).n" +
                                " You can also use this weapon to make trip attacks.n" +
                                " If you are tripped during your own trip attempt, you can drop the dire flail to avoid being tripped.n");
                        Flaildire.putExtra("Source","Dragon #355");
                        startActivity(Flaildire);
                        break;
                    case 5: Intent GarroteRing=new Intent(getApplicationContext(),dettagli_armi.class);
                        GarroteRing.putExtra("costo","50 gp");
                        GarroteRing.putExtra("dannis","1D6");
                        GarroteRing.putExtra("dannim","1D8");
                        GarroteRing.putExtra("crit","18-20");
                        GarroteRing.putExtra("rangeinc","-");
                        GarroteRing.putExtra("weight","- lb.");
                        GarroteRing.putExtra("type","Slashing.n");
                        GarroteRing.putExtra("dettagli","The wearer of this large, ostentatious ring can detach the gem atop it and pull forth a length of extremely fine, tough wire that can be used to strangle an opponent.n" +
                                " Pulling out the wire is a free action, but rewinding it requires a full-round action.n" +
                                " A garrotte attack uses the grappling rules from the Player's Handbook, with a few additions.n");
                        GarroteRing.putExtra("Source","Dragon #316");
                        startActivity(GarroteRing);
                        break;
                    case 6: Intent LockingMechanism=new Intent(getApplicationContext(),dettagli_armi.class);
                        LockingMechanism.putExtra("costo","-");
                        LockingMechanism.putExtra("dannis","-");
                        LockingMechanism.putExtra("dannim","-");
                        LockingMechanism.putExtra("crit","-");
                        LockingMechanism.putExtra("rangeinc","-");
                        LockingMechanism.putExtra("weight","-");
                        LockingMechanism.putExtra("type","Exotic");
                        LockingMechanism.putExtra("dettagli","Strangle Bonus=-.n" +
                                " Two-handed.n" +
                                "n" +
                                " A locking mechanism consists of a pair of handles that attach to any thin, supple item (such as a rope, steel cable, wire, and so on).n" +
                                " The handles slide along the garroting material freely, but when brought together they can lock in place together.n" +
                                " Once you secure the garrote you can lock the garrote in place with a move action.n" +
                                "n" +
                                " This maintains strangling pressure on your opponent even after you let go.n" +
                                " The garroted creature continues to make grapple checks (each one opposed by the last grapple check you made) until freed or unconscious.n" +
                                " Unlocking the handles from each other is a free action.n" +
                                " Adding a locking mechanism to a garrote makes the garrote an exotic weapon.n" +
                                "n" +
                                " The DC for a Disable Device check made to remove a locked garrote is 10 if the character has Exotic Weapon Proficiency (locking garrote) or 25 if she does not.n" +
                                " If someone other than the victim makes the attempt, a -5 penalty applies unless the garroted character is held, unconscious, or otherwise kept from moving.n" +
                                "n" +
                                " A character attempting to remove a locked garrote from around his own neck takes a -5 penalty for working blindly.n" +
                                " A character cannot take 10 or take 20 on this check unless the creature garroted is already dead.n" +
                                " Failing a Disable Device check by 5 or more causes the victim to lose an additional round's worth of air (or deals a round's worth of damage, if using those rules).n");
                        LockingMechanism.putExtra("Source","Dragon #355");
                        startActivity(LockingMechanism);
                        break;
                    case 7: Intent Rope=new Intent(getApplicationContext(),dettagli_armi.class);
                        Rope.putExtra("costo","varies");
                        Rope.putExtra("dannis","1D3");
                        Rope.putExtra("dannim","1D4");
                        Rope.putExtra("crit","-");
                        Rope.putExtra("rangeinc","-");
                        Rope.putExtra("weight","-");
                        Rope.putExtra("type","varies");
                        Rope.putExtra("dettagli","Strangle Bonus=1.n" +
                                " Two-handed.n" +
                                "n" +
                                " A standard piece of adventuring equipment, a rope can be used as a garrote.n");
                        Rope.putExtra("Source","Dragon #355");
                        startActivity(Rope);
                        break;
                    case 8: Intent Sling=new Intent(getApplicationContext(),dettagli_armi.class);
                        Sling.putExtra("costo","1 gp");
                        Sling.putExtra("dannis","1D2");
                        Sling.putExtra("dannim","1D3");
                        Sling.putExtra("crit","-");
                        Sling.putExtra("rangeinc","-");
                        Sling.putExtra("weight","0 lb.");
                        Sling.putExtra("type","-");
                        Sling.putExtra("dettagli","Strangle Bonus=1.n" +
                                " Two-handed.n" +
                                "n" +
                                " The sling hurls lead bullets.n" +
                                " It's nor as easy to use as the crossbow nor as powerful as a bow, but it's cheap, and easy to improvise from common materials.n" +
                                " Druids and halflings favor slings.n" +
                                "n" +
                                " You can hurl ordinary stones with a sling, but stones are not as dense or as round as bullets, so you deal only 1d3 points of damage and suffer a -1 penalty on attack rolls.n");
                        Sling.putExtra("Source","Dragon #355");
                        startActivity(Sling);
                        break;
                    case 9: Intent SteelCable=new Intent(getApplicationContext(),dettagli_armi.class);
                        SteelCable.putExtra("costo","60 gp");
                        SteelCable.putExtra("dannis","1D6");
                        SteelCable.putExtra("dannim","1D8");
                        SteelCable.putExtra("crit","-");
                        SteelCable.putExtra("rangeinc","-");
                        SteelCable.putExtra("weight","1 lb.");
                        SteelCable.putExtra("type","-");
                        SteelCable.putExtra("dettagli","Strangle Bonus=3.n" +
                                " Two-handed.n" +
                                "n" +
                                " Steel cable has hardness 8, 8 hit points, and a break DC of 26.n" +
                                " Price is for 5 ft.");
                        SteelCable.putExtra("Source","Dragon #355");
                        startActivity(SteelCable);
                        break;
                    case 10: Intent Whip=new Intent(getApplicationContext(),dettagli_armi.class);
                        Whip.putExtra("costo","1 gp");
                        Whip.putExtra("dannis","1D6");
                        Whip.putExtra("dannim","1D8");
                        Whip.putExtra("crit","-");
                        Whip.putExtra("rangeinc","-");
                        Whip.putExtra("weight","2 lb.");
                        Whip.putExtra("type","Exotic");
                        Whip.putExtra("dettagli","Strangle Bonus=3.n" +
                                " Two-handed.n" +
                                "n" +
                                " The whip deals subdual damage.n" +
                                " It deals no damage to any creature with even a +1 armor bonus or at least a +3 natural armor bonus.n" +
                                " Although you keep it in hand, treat it as a projectile weapon with a maximum range of 15 feet and no range penalties.n" +
                                "n" +
                                " Because the whip can wrap around an enemy's leg or other limb, you can make trip attacks with it.n" +
                                " If you are tripped during your own trip attempt, you can drop the whip to avoid being tripped.n" +
                                "n" +
                                " When using a whip, you get a +2 bonus on your opposed attack roll when attempting to disarm an opponent (including the roll to keep from being disarmed if you fail to disarm your opponent).n");
                        Whip.putExtra("Source","Dragon #355");
                        startActivity(Whip);
                        break;
                    case 11: Intent Wire=new Intent(getApplicationContext(),dettagli_armi.class);
                        Wire.putExtra("costo","25 gp");
                        Wire.putExtra("dannis","1D4");
                        Wire.putExtra("dannim","1D6");
                        Wire.putExtra("crit","-");
                        Wire.putExtra("rangeinc","-");
                        Wire.putExtra("weight","0 lb.");
                        Wire.putExtra("type","-");
                        Wire.putExtra("dettagli","Strangle Bonus=3.n" +
                                " Two-handed.n" +
                                "n" +
                                " Most wire garrotes come with grips at the ends.n" +
                                " Using a wire garrote without grips or some kind of hand protection deals 1d3 points of damage per round to you.n" +
                                " Wire has hardness 4, 5 hit points, and a break DC of 24.n" +
                                " Assumes 5 ft. length.n");
                        Wire.putExtra("Source","Dragon #355");
                        startActivity(Wire);
                        break;

            }
        }
    });

}

}

Aucun commentaire:

Enregistrer un commentaire