私はScrollviewを持っていて、Scrollviewの内部はTextViewsです。スクロールビューからデータを渡す方法
これらのテキストビューデータをインテントを通じて別のScrollviewに渡したいとします。
私はScrollviewを持っていて、Scrollviewの内部はTextViewsです。スクロールビューからデータを渡す方法
これらのテキストビューデータをインテントを通じて別のScrollviewに渡したいとします。
インテントで他のアクティビティを開く場合は、 intentName.putExtra();
を使用できます。
まず、xmlからtextview IDのデータを取得する必要があります(scrollview.weがXMLファイルであるかどうかにかかわらず)。 例に
1.activity.xmlに従ってください:
<RelativeLayout
android:id="@+id/one"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="30dp">
<TextView
android:id="@+id/txtname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview1" />
</ScrollView>
</RelativeLayout>
2.InあなたMainActivity.java
public class MainActivity extends AppCompatActivity {
TextView txtname;
String name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//to get the textview from xml
txtname = (TextView) findViewById(R.id.txtname);
name = txtname.getText().toString();
//to send this name u need to call intent
Intent intent_data = new Intent(this, ActivityTwo.class);
//by using pupExtra method we can send the data from one activity to another
intent_data.putExtra("Name", name);
startActivity(intent_data);
}
}
ありがとうございますので、私はテキストビューのデータを過ぎていますか? –
はい。データを受け取ります – user5607081
私はこれが有用であると感じたら、私の答えを受け入れてください。 – user5607081
これは非常にあいまいです。送信する必要があるデータは何ですか?どのように構造化されていますか?あなたが何をしたかを示してください – SoroushA
他のアクティビティをどうやって開くのですか?意図をもって? –
あなたの質問は明確ではありません。誰もスクロールビューで別のアクティビティにデータを送信しません。あなたのコードは何ですか? –