Autore Topic: Listview e edittex search [Risolto]  (Letto 302 volte)

Offline luy96

  • Nuovo arrivato
  • *
  • Post: 4
  • Respect: 0
    • Mostra profilo
Listview e edittex search [Risolto]
« il: 10 Giugno 2016, 13:17:45 CEST »
0
salve ragazzi sono nuovo del sito e vorrei ringraziarvi per prima cosa  :-) :-)
Ho questo problema ho creato una listview molto lunga, e ho inserito una edit text al top della activity x velocizare la ricerca funziona tutto alla perferzione ma quando inserisco una parola mela trova nella lista ma quando clicco sopra non mi apre quella che voglio ma mi apre le quelle iniziali.

Codice (XML): [Seleziona]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context="jekan.myapplication.Garrote"
   android:clickable="false"
   android:visibility="visible">


    <EditText
       android:layout_width="match_parent"
       android:layout_height="40dp"
       android:layout_alignParentTop="true"
       android:layout_alignParentLeft="true"
       android:layout_alignParentStart="false"
       android:id="@+id/editTextgarrote"
       android:hint="@string/search_hint"
       />

    <ListView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:id="@+id/listViewgarroteweapong"
       android:layout_below="@+id/editTextgarrote"
       android:layout_alignParentLeft="true"
       android:layout_alignParentStart="true" />
</RelativeLayout>


Codice (Java): [Seleziona]
package jekan.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

public class Garrote extends AppCompatActivity {

    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<String>(this, android.R.layout.simple_list_item_1, listaarmigarrote);
        ListView listaarmigarrote = (ListView) findViewById(R.id.listViewgarroteweapong);

        listaarmigarrote.setAdapter(adapter);
        listaarmigarrote.setTextFilterEnabled(true);
        EditText editTextgarrote=(EditText)findViewById(R.id.editTextgarrote);
        editTextgarrote.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) {

            }
        });
        listaarmigarrote.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position==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);
                }
                if (position==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);
                }
                if (position==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);
                }
                if (position==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);
                }
                if (position==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);
                }
                if (position==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);
                }
                if (position==6) {
                    ; 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" +
                            " Two-handed.\n" +
                            "\n" +
                            " Cord has hardness 0, 2 hit points, and a break DC of 20.\n" +
                            " Price is for 5 ft.\n");
                    Cord.putExtra("Source","Dragon #355");
                    startActivity(Cord);
                }
                if (position==7) {
                    ; 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);
                }
                if (position==8) {
                    ; 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);
                }
                if (position==9) {
                    ; 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);
                }
                if (position==10) {
                    ; 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);
                }
                if (position==11) {
                    ; 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);
                }
                if (position==12) {
                    ; 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);
                }

            }
        });
    }
}

Grazie x l'aiuto :D :-P
« Ultima modifica: 18 Giugno 2016, 00:33:15 CEST da luy96 »

Offline tonno16

  • Utente storico
  • *****
  • Post: 1169
  • Respect: +56
    • Mostra profilo
  • Dispositivo Android:
    moto g
  • Play Store ID:
    Diego Tonini
  • Sistema operativo:
    OpenSuse
Re:Listview e edittex search
« Risposta #1 il: 10 Giugno 2016, 14:03:47 CEST »
0
Non so.prova a loggare e cedere che valore assume position. In ogni caso é sbagliata la tua progettszione. Inutile fare 30 if all click

Offline luy96

  • Nuovo arrivato
  • *
  • Post: 4
  • Respect: 0
    • Mostra profilo
Re:Listview e edittex search
« Risposta #2 il: 10 Giugno 2016, 14:41:36 CEST »
0
questo e da quando clicco sulla edit x scrivere

06-10 08:40:58.569 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
06-10 08:40:58.569 297-363/system_process W/AudioService: onLoadSoundEffects(), Error -1 while loading samples
06-10 08:40:58.689 297-475/system_process D/dalvikvm: GC_FOR_ALLOC freed 675K, 33% free 11549K/17104K, paused 88ms, total 92ms
06-10 08:40:58.819 297-475/system_process D/dalvikvm: GC_FOR_ALLOC freed 1294K, 37% free 10898K/17104K, paused 112ms, total 113ms
06-10 08:40:59.129 17157-17157/jekan.myapplication D/dalvikvm: GC_FOR_ALLOC freed 1344K, 28% free 8695K/12072K, paused 41ms, total 55ms
06-10 08:40:59.149 17157-17157/jekan.myapplication I/dalvikvm-heap: Grow heap (frag case) to 10.588MB for 1939936-byte allocation
06-10 08:40:59.209 17157-17166/jekan.myapplication D/dalvikvm: GC_FOR_ALLOC freed 2242K, 41% free 8347K/13968K, paused 62ms, total 62ms
06-10 08:40:59.489 17157-17157/jekan.myapplication W/EGL_emulation: eglSurfaceAttrib not implemented
06-10 08:41:00.089 297-313/system_process I/ActivityManager: Displayed jekan.myapplication/.Garrote: +1s235ms
06-10 08:41:09.169 297-461/system_process I/ActivityManager: START u0 {cmp=jekan.myapplication/.dettagli_armi (has extras)} from pid 17157
06-10 08:41:09.213 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.213 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.213 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.213 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.219 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.219 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.219 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.219 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.219 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.219 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
06-10 08:41:09.219 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressStandard.ogg
06-10 08:41:09.219 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
06-10 08:41:09.219 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressSpacebar.ogg
06-10 08:41:09.219 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
06-10 08:41:09.219 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressDelete.ogg
06-10 08:41:09.229 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
06-10 08:41:09.229 297-363/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressReturn.ogg
06-10 08:41:09.229 297-363/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
06-10 08:41:09.229 297-363/system_process W/AudioService: onLoadSoundEffects(), Error -1 while loading samples
06-10 08:41:09.389 297-461/system_process D/dalvikvm: GC_FOR_ALLOC freed 731K, 33% free 11556K/17104K, paused 108ms, total 111ms
06-10 08:41:09.489 297-461/system_process D/dalvikvm: GC_FOR_ALLOC freed 1292K, 37% free 10905K/17104K, paused 76ms, total 77ms
06-10 08:41:09.799 17157-17157/jekan.myapplication D/dalvikvm: GC_FOR_ALLOC freed 1347K, 38% free 8714K/13968K, paused 84ms, total 91ms
06-10 08:41:10.220 17157-17157/jekan.myapplication W/EGL_emulation: eglSurfaceAttrib not implemented
06-10 08:41:10.621 17157-17157/jekan.myapplication I/Choreographer: Skipped 30 frames!  The application may be doing too much work on its main thread.
06-10 08:41:11.539 297-313/system_process I/ActivityManager: Displayed jekan.myapplication/.dettagli_armi: +2s25ms


Post unito: 10 Giugno 2016, 20:56:08 CEST
:-(nessuna idea xké nn funziona???
« Ultima modifica: 10 Giugno 2016, 20:56:08 CEST da luy96, Reason: Merged DoublePost »

Offline Carni

  • Nuovo arrivato
  • *
  • Post: 41
  • Respect: +3
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy S3
  • Play Store ID:
    R3D5HA
  • Sistema operativo:
    Windows 10
Re:Listview e edittex search
« Risposta #3 il: 15 Giugno 2016, 14:20:55 CEST »
0
Quando entri nell'evento onItemClick, position acquista il valore della riga selezionata, quindi se clicchi sulla prima hai come valore 0, sulla seconda 1 ecc. Il tuo ragionamento funzionerebbe se la lista fosse statica.
Però applicando il filtro all'adapter la lista non è più statica perchè ogni volta che digiti qualcosa all'interno della editText cambia e quindi ciò che prima era alla posizione 0 ora non lo è più.
L'errore dovrebbe essere questo. Per risolverlo ti consiglio invece di creare un controllo sulla posizione di controllare il valore sulla posizione selezionata. Per ottenere il valore fai:
 
Codice (Java): [Seleziona]
String value = adapter.getItem(position);

Offline luy96

  • Nuovo arrivato
  • *
  • Post: 4
  • Respect: 0
    • Mostra profilo
Re:Listview e edittex search
« Risposta #4 il: 17 Giugno 2016, 18:55:40 CEST »
0
ciao ti ringrazio della risposta nn ti ho potuto rispondere prima x problemi di internet
senti sincero nn ho capito tanto sono nuovo della programazione mi potresti fare un esempio  :-) :-)grazie

Offline Carni

  • Nuovo arrivato
  • *
  • Post: 41
  • Respect: +3
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy S3
  • Play Store ID:
    R3D5HA
  • Sistema operativo:
    Windows 10
Re:Listview e edittex search
« Risposta #5 il: 17 Giugno 2016, 19:30:06 CEST »
0
Ti faccio vedere come si fa per il primo oggetto nel vettore di stringhe che hai creato ("Bolas"):
Codice (Java): [Seleziona]
listaarmigarrote.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String value = adapter.getItem(position);
                if (value.equals("Bolas")) {
                    Intent Bolas=new Intent(getApplicationContext(),dettagli_armi.class);
                    //Tutto ciò che vuoi
                }
            }
});
In questo modo controlli il valore e non la posizone.

Offline luy96

  • Nuovo arrivato
  • *
  • Post: 4
  • Respect: 0
    • Mostra profilo
Re:Listview e edittex search
« Risposta #6 il: 17 Giugno 2016, 20:04:57 CEST »
0
 :-) :-) :-) :-)
funziona finalmente grazie mille  :-[ :-[ :-[ :-[

Offline Carni

  • Nuovo arrivato
  • *
  • Post: 41
  • Respect: +3
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy S3
  • Play Store ID:
    R3D5HA
  • Sistema operativo:
    Windows 10
Re:Listview e edittex search
« Risposta #7 il: 17 Giugno 2016, 20:23:06 CEST »
0
Bene  :-) metti come risolto