开发者

Automated Spinner Selection in android

I am developing an android which has 4 spinners(A,B,C,D). What I want to achieve is If Spinner A is set to a value I want the remaining spinners to automatically change their value depending on the value of A

Like if I set Movie(in A)--->Ticket(in B)---->Place(in C)---->Time(D) to automatically fill in.

开发者_如何学JAVA

Thanking you ChinniKrishna Kothapalli


I think you can set an OnItemSelectedListener to your Movie Spinner. The Spinner tutorial is an adequate example. Your OnItemSelectedListener may be like this:

public class MyOnItemSelectedListener implements OnItemSelectedListener {

    public void onItemSelected(AdapterView<?> parent,
        View view, int pos, long id) {
        if (parent.getItemAtPosition(pos).toString().equals("firstMovieName")) {
            // set spinner B/C/D with the corresponding information of first movie
        }
    }

    public void onNothingSelected(AdapterView parent) {
      // Do nothing.
    }
}

The onItemSelected method above may be too simple for your need. You need figure it out how to link the four spinners yourself, but May it helps :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜