getIntExtra始终返回默认值

时间:2016-02-03 19:26:09

标签: java android android-intent

请帮助我,我不明白这有什么问题.. 被叫活动中的k值始终为1。

我的来电活动代码

            pos_st = position;
            Intent newActivity = new Intent(branch.this, BranchInfo.class);
            lk= idnum[pos_st];
            int x=Integer.parseInt(lk);
            newActivity.putExtra("idnumber",x);
            Toast.makeText(getApplicationContext(), "X :" + x, Toast.LENGTH_LONG).show();
            startActivity(newActivity);

调用活动

Intent intent = new Intent();
int k =intent.getIntExtra("idnumber",1);

1 个答案:

答案 0 :(得分:2)

您不想在被调用的活动中创建<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myApp" ng-controller="ctrl"> <select ng-model="shipping.addressLine1" ng-options="shipping.shipping for shipping in shipAddress"> <option value=''>--Select Address --</option> </select> <br /> <pre> {{shipping | json}}<br /> {{shipping.addressLine1 | json}} </pre> <form name="shippingForm" class="form-horizontal" role="form"> <div class="form-group"> <p class="control-p col-sm-2" for="Address">Address Line1</p> <div class="col-sm-10"> <input type="text" name="Address" placeholder="Address Line1" ng-model="shipping.addressLine1.shipping" class="input-width" ng-init ="shipping.addressLine1"/> </div> </div> <div class="form-group"> <p class="control-p col-sm-2" for="Address2">Address Line2:</p> <div class="col-sm-10"> <input type="text" name="AddressLine" placeholder="Address Line2" ng-model="shipping.addressLine2" class="input-width" /> </div> </div> </form> </div>

而是尝试使用以下内容获取用于启动new Intent()的{​​{1}}:

Intent