0
FAB를 클릭하면 메시지을 공유 할 수있게하려고합니다. 하지만 여기에 sendIntent.putExtra(Intent.EXTRA_TEXT, /* what should I put here*/);
은 무엇을 배치해야합니까? 메시지을 시도했지만 작동하지 않습니다.의도 입력 텍스트 입력
public class NoteDetailFragment extends Fragment {
public NoteDetailFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View fragmentLayout = inflater.inflate(R.layout.fragment_note_detail, container, false);
FloatingActionButton fab = (FloatingActionButton)fragmentLayout.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, /* what should I put here*/);
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
});
TextView title = (TextView)fragmentLayout.findViewById(R.id.viewNoteTitle);
TextView message = (TextView)fragmentLayout.findViewById(R.id.viewNoteMessage);
TextView thoughts = (TextView)fragmentLayout.findViewById(R.id.viewNoteThoughts);
ImageView icon = (ImageView)fragmentLayout.findViewById(R.id.viewNoteIcon);
Intent intent = getActivity().getIntent();
title.setText(intent.getExtras().getString(MainActivity.NOTE_TITLE_EXTRA));
message.setText(intent.getExtras().getString(MainActivity.NOTE_MESSAGE_EXTRA));
thoughts.setText(intent.getExtras().getString(MainActivity.NOTE_THOUGHTS_EXTRA));
Note.Category noteCat = (Note.Category)intent.getSerializableExtra(MainActivity.NOTE_CATEGORY_EXTRA);
icon.setImageResource(Note.categoryToDrawable(noteCat));
return fragmentLayout;
}
}
당신은 일반 텍스트로하는'String'에 전달해야합니다 : 여기
는 Tutorial에서 예입니다. 이 문자열이 어디에서 왔는지 직접 결정해야합니다. 여기에서 공유 할 텍스트를 아는 유일한 사람이 있습니다. – CommonsWare오, 그래서 사용자가 입력 한 텍스트를 보내는 것은 정말 불가능합니다. – Kimochis
아니, 아주 가능합니다. 그러나 사용자가이 텍스트를 어디에 입력하는지는 알 수 없습니다. 소스 코드는'EditText'의 흔적을 보여주지 않습니다. – CommonsWare