在选择微调器时,我需要离开处于框架布局中的图像视图的顶部。这是我的代码。
location_spinner.setOnItemSelectedListener(new OnItemSelectedListener()
{
String scr;
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position1, long id)
{
selscr = location_spinner.getSelectedItem().toString();
src_position = position1;
System.out.println("selscr--->"+selscr);
System.out.println("src_position--->"+src_position);
floor_code=selscr.substring(selscr.length() - 1);
System.out.println("The selscr"+floor_code);
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{
// TODO Auto-generated method stub
}
});
get_location_bt.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View arg0)
{
if(src_position==0)//selscr.equalsIgnoreCase("-Select-") && seldes.equalsIgnoreCase("-Select-"))
{
ground_image.setBackgroundResource(R.drawable.gray);
}
else if(floor_code.equalsIgnoreCase("G"))
{
ground_frame2.setVisibility(View.INVISIBLE);
new_rad.setVisibility(View.INVISIBLE);
System.out.println("new_rad before id"+new_rad.getId());
new_rad = ver.get(src_position-1);
//new_rad.setBackgroundResource(R.drawable.location_icon);
new_rad.setVisibility(View.VISIBLE);
System.out.println("new_rad after id"+new_rad.getId());
int x_value = new_rad.getLeft();
int y_value = new_rad.getTop();
System.out.println("x_value + y_value---->"+x_value+y_value);
ground_frame2.setLeft((int) (1500/3.0-x_value));
ground_frame2.setTop((int)(1119/3.0-y_value));
ground_frame2.setVisibility(View.VISIBLE);
}
}
});
当我像这样使用它时,它工作得很好。
Intent gound_fr = new Intent(LocateStore.this,GroundLoc.class);
gound_fr.putExtra("src",src_position);
但是当我在 else if 部分中使用意图时,它不会得到 X 和 Y 值。这些方法返回为零。我该如何解决这个问题?谁能告诉我?提前致谢。