انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
دکمه next , previous در لیست ویو، در برنامه نویسی اندروید

دکمه next , previous در لیست ویو، در برنامه نویسی اندروید

#6
حالا اگه بخوایید به صورت لیست درشون بیارید صفحه ی لیست اینطوری میشه :

کد:
public class MainActivity extends Activity {
    private Activity t;

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

        final String[] item ={"موضوع1 " , "موضوع 2" };
        ListView list=(ListView) findViewById(R.id.listView);
        t=this;
        list.setAdapter(new ArrayAdapter<String>(this,R.layout.row,R.id.row_txt,item));

        final Intent next = new Intent(MainActivity.this, nextActivity.class);


        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            public void onItemClick(AdapterView<?> arg0, View arg1, int indexItem, long arg3) {
                switch (indexItem) {
                    case 0:
                        next.putExtra("txt","متن مورد نظر 1");
                        next.putExtra("lst", 0);
                        startActivity(next);
                        break;
                    case 1:
                        next.putExtra("txt","متن مورد نظر 2");
                        next.putExtra("btn", 1);
                        startActivity(next);
                        break;

                }
            }

        });
    }

و اکتیویتی حاوی اطلاعات که اینجا متنه هم به این شکل میشه :

کد:
public class nextActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.next_layout );


        Intent intent = getIntent();
        final int[] lst = {intent.getExtras().getInt("lst")};
        String txtn = intent.getExtras().getString("txt");


        TextView txt = (TextView)findViewById(R.id.textView);

        switch (lst[0]){
            case 0 :
                txt.setText(txtn);
                break;
            case 1 :
                txt.setText(txtn);
                break;

        }

    }
}
پاسخ
 سپاس شده توسط admin


پیام‌های این موضوع
RE: دکمه next , previous در لیست ویو - توسط admin - ۱۳۹۳/۰۹/۱۵, ۰۳:۲۰ ب.ظ
RE: دکمه next , previous در لیست ویو، در برنامه نویسی اندروید - توسط aliasghar - ۱۳۹۳/۰۹/۱۵, ۰۸:۵۶ ب.ظ

پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان