ImageView
처음으로 프로그래밍 방식으로 추가 할 때 표시 ImageView
되지만 두 번째로 충돌이 발생합니다.
imgtest = (ImageView) findViewById(R.id.someID);
imgtest.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Medtconversation = edtconversation.getText().toString();
edtconversation.setText("");
if(Medtconversation.length() > 0)
{
if (flagTyp == true) {
I add Image View Here------->imageView.setImageResource(R.drawable.chat_logo);
--->imageView.setLayoutParams(new LayoutParams(
---> LayoutParams.MATCH_PARENT,
---> LayoutParams.WRAP_CONTENT));
--->rilative.addView(imageView);<---- Line 286
txtviewUser = new TextView(ConversationPage.this);
txtviewUser.setText(Medtconversation);
txtviewUser.setTextColor(Color.BLUE);
txtviewUser.setTypeface(null, Typeface.BOLD);
txtviewUser.setTextSize(TypedValue.COMPLEX_UNIT_SP,25);
txtviewUser.setPadding(20, 5, 20, 10);
rilative.setBackgroundResource(R.drawable.conversation_shap);
rilative.addView(txtviewUser);
MyTaskParams params = new MyTaskParams(Integer
.parseInt(UserID), 0, Integer.parseInt(IDEtegh),
Integer.parseInt(IDSharee), UserNAME, NSharee,
NEtegh, Medtconversation, URL);
MySendMessage sendmsg = new MySendMessage();
try {
String Rest = sendmsg.execute(params).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
flagTyp = false;
}
}
그리고 내 Layout Xml
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollID"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/brown"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/lineartwo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="true"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:weightSum="1.5"
android:background="@drawable/bottom_conversation">
<TextView
android:id="@+id/isTyping"
android:layout_width="0dip"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:hint="Chat" />
<EditText
android:id="@+id/txtInpuConversation"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:hint="@string/edt_Conversation" >
<requestFocus />
</EditText>
<ImageButton
android:id="@+id/someID"
android:layout_width="0dip"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:background="@drawable/background_selector"
android:contentDescription="@null"
android:layout_marginTop="5dp"
android:src="@drawable/social_send_now" />
</LinearLayout>
</LinearLayout>
오류 :
by Log tag : AndroidRuntime
by Log Message : at com.test.onlinechattwo.ConversationPage$3.onClick(ConversationPage.java:286)
귀하의 코드를주의 깊게 살펴 보겠습니다. 귀하의 채팅 앱이 다음과 같기를 바랍니다.
그렇다면 ImageView
한 번만 추가해야 하므로 코드를 편집하십시오.
boolean flgaimage = false; (In you activity)
그리고 다음을 편집하십시오 ClickListener
.
.........
if (flagTyp == true) {
if(flgaimage == false)
{
imageView.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
rilative.addView(imageView);
flgaimage = true;
}
.............
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다