PDA

View Full Version : دکمه ی اشتراک متن در لیست ویو



aryan99
شنبه 22 شهریور 1393, 16:00 عصر
سلام
من در ListViewAdapter.java دکمه اشتراک متن تعریف کردم ولی قسمت startactivity اصلا کار نمی کنه
لطفا کمکم کنید که باید چه کار کنم ؟

اینم کد :
OnClickListener clickListener = new OnClickListener() {

@Override
public void onClick(View v) {
try{
Context context = v.getContext();
String ab = (String) holder.tvComment.getText();
holder.tvComment.setText(ab);

Toast.makeText(context, ab, Toast.LENGTH_LONG).show();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);

sendIntent.putExtra(Intent.EXTRA_TEXT, ab);
sendIntent.setType("text/plain");


context.startActivity(sendIntent);

}
catch (Exception e){
Log.w("Share Data", "Error!");
}

}
};


holder.sharebtn.setOnClickListener(clickListener);

harani
شنبه 22 شهریور 1393, 16:56 عصر
از این متد استفاده کن برای استراک گذاری :


public void shareData(String Title, String Message) {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = Message;
sharingIntent.putExtra(android.content.Intent.EXTR A_SUBJECT, Title);
sharingIntent.putExtra(android.content.Intent.EXTR A_TEXT, shareBody);
context.startActivity(Intent.createChooser(sharing Intent, "Share via"));
}

aryan99
شنبه 22 شهریور 1393, 17:08 عصر
ممنون میشه به این سوالم پاسخ بدی ؟
یه جا پرسیدم گفت باید ویو براش بزارم ولی نمی دونم چجوری
اینو ببینین :

http://stackoverflow.com/questions/25823279/how-to-set-view-for-listadapter

harani
شنبه 22 شهریور 1393, 17:54 عصر
سرچ کن android code create custom listview example

http://www.vogella.com/tutorials/AndroidListView/article.html

http://www.bignerdranch.com/blog/customizing-android-listview-rows-subclassing/