在活动 WorkDetailsTable 中,它有一个ListView
,如下所示。单击时,它应显示 Add_Details_Information EditText
假设点击了第一个列表,并且意图 Add_Details_Information
注意到editText上的值实际上来自活动A 中的第二个列表。但我想要的是相应的价值而不是最新的价值。
WorkDetailsTable
int mClickedPosition;
MyCustomBaseAdapter objMyCustomBaseAdapter;
ArrayList<SearchResults> results=new ArrayList<SearchResults>();
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { // if listView is clicked
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
mClickedPosition = position;
// how to getPosition???
Intent i = new Intent(getApplication(), Add_Details_Information.class);
i.putExtra("ReceiveProject", ReceiveProject);
i.putExtra("ReceiveDescription", ReceiveDescription);
i.putExtra("ReceiveProgress", ReceiveProgress);
i.putExtra("ReceiveTimeIn", ReceiveTimeIn);
i.putExtra("ReceiveTimeOut", ReceiveTimeOut);
i.putExtra("date",date);
i.putExtra("status", status);
startActivityForResult(i,PROJECT_REQUEST_CODE);
}
});
}
Add_Details_Information
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.add_details_information);
addItemsOnSpinner(); // Spinner for project/service/training
tp = new TimePick(); // call tmePick
description=(EditText)findViewById(R.id.editTextWorkDescription);
timeIn=(EditText)findViewById(R.id.TimeIn);
timeOut=(EditText)findViewById(R.id.TimeOut);
save=(Button)findViewById(R.id.saveButton);
seekBar=(SeekBar)findViewById(R.id.seekBarPercentage);
progressText=(TextView)findViewById(R.id.textProgress);
progressText.setText("Covered:" + "" + seekBar.getProgress() + "/" + seekBar.getMax());
if(getIntent().getExtras()!=null)
{
final String Project1=getIntent().getStringExtra("ReceiveProject");
final String Description1=getIntent().getStringExtra("ReceiveDescription");
final int Progress1=getIntent().getIntExtra("ReceiveProgress", 0);
final String TimeIn1=getIntent().getStringExtra("ReceiveTimeIn");
final String TimeOut1=getIntent().getStringExtra("ReceiveTimeOut");
// project.setText(Project1);
description.setText(Description1);
seekBar.setProgress(Progress1);
timeIn.setText(TimeIn1);
timeOut.setText(TimeOut1);
seekBar.setProgress(Progress1);
progressText.setText("Covered:" + "" + seekBar.getProgress() + "/" + seekBar.getMax());
}
MyCustomBaseAdapter
public class MyCustomBaseAdapter extends BaseAdapter{ // for ListView in WorkDetailsTable
private static ArrayList<SearchResults> searchArrayList;
private LayoutInflater mInflater;
public MyCustomBaseAdapter(Context context, ArrayList<SearchResults> results) {
searchArrayList = results;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return searchArrayList.size();
}
public Object getItem(int position) {
return searchArrayList.get(position);
}
public long getItemId(int position) {
return position;
}
public void addNewItem(String P,String D,int Per,String I,String O)
{
SearchResults obj=new SearchResults();
obj.setProject(" Project/Service/Training : "+P);
obj.setDescription(" Work Description : " + D);
obj.setProgress(" Progress : " + Per);
obj.setTimeIn(" Time In : " + I);
obj.setTimeOut(" Time Out : " + O);
searchArrayList.add(obj);
this. notifyDataSetChanged();
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.custom_row_view, null);
holder = new ViewHolder();
holder.txtProject= (TextView) convertView.findViewById(R.id.ListProject);
holder.txtDescription = (TextView) convertView.findViewById(R.id.ListDescription);
holder.txtProgress = (TextView) convertView.findViewById(R.id.ListProgress);
holder.txtIn=(TextView)convertView.findViewById(R.id.ListTimeIn);
holder.txtOut=(TextView)convertView.findViewById(R.id.ListTimeOut);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txtProject.setText(searchArrayList.get(position).getProject());
holder.txtDescription.setText(searchArrayList.get(position).getDescription());
holder.txtProgress.setText(searchArrayList.get(position).getProgress());
holder.txtIn.setText(searchArrayList.get(position).getTimeIn());
holder.txtOut.setText(searchArrayList.get(position).getTimeOut());
return convertView;
}
static class ViewHolder {
TextView txtProject;
TextView txtDescription;
TextView txtProgress;
TextView txtIn;
TextView txtOut;
}
}
试用代码
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { // if listView is clicked
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
Object o=listview.getItemAtPosition(position);
SearchResults fullObject=(SearchResults)o;
String ReceiveDescription=((SearchResults) o).getDescription();
Intent i = new Intent(getApplication(), Add_Details_Information.class);
i.putExtra("ReceiveDescription", ReceiveDescription);
startActivityForResult(i,PROJECT_REQUEST_CODE);
}
});
}
答案 0 :(得分:0)
试试这个:
$(".play").on('click', function () {
var key = $(this).attr('key');
var this_play = $(this);
$(".play").each(function () {
if ($(this)[0] != this_play[0]) {
$(this).removeClass("pause");
}
});
$(this).toggleClass("pause");
var player_bottom = $(".playerbottom");
if (currentKey == key || !player_bottom.hasClass('pausebottom')) {
player_bottom.toggleClass("pausebottom");
}
EvalSound(this, key);
});
var thissound = new Audio();
var currentKey;
function EvalSound(el, key) {
thissound.addEventListener('ended', function () {
// done playing
$(el).removeClass("pause");
$(".playerbottom").removeClass("pausebottom");
});
if (currentKey !== key) thissound.src = "http://99centbeats.com/1e4cb5f584d055a0992385c1b2155786/" + key + ".mp3";
currentKey = key;
if (thissound.paused) thissound.play();
else thissound.pause();
//thissound.currentTime = 0;
currentPlayer = thissound;
}
$(".volume_slider").slider({
value : 75,
step : 1,
range : 'min',
min : 0,
max : 100,
slide : function(){
var value = $(".volume_slider").slider("value");
thissound.volume = (value / 100);
}
});