Is there any Data Grid control available for android? - android

I am looking for including a pre-built data grid control in a data-driven to display data in a tabular form just like we do in desktop or web applications. I am aware that there are alternate ways available just like we have it here:
How to create a DataGrid display in android?
Any other good alternate?

I wrote one. It supports image buttons, text view and edit text. Clicking on a column header will sort the data. Also a column can be set as clickable. If interested I can send you my code.
Here is a sample layout file using the code.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:tg="http://schemas.android.com/apk/res/com.ra.music"
xmlns:pc="http://schemas.android.com/apk/res/com.ra.music"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MusicActivity" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/music_header" />
<com.ra.playercontrol.PlayerControl
android:id="#+id/player_control"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
pc:editSong="true" />
<ScrollView
android:id="#+id/table_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:scrollbars="vertical|horizontal" >
<com.ra.tablegrid.TableGrid
android:id="#+id/music_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:stretchColumns="*" >
<com.ra.tablegrid.TableTextView
android:id="#+id/song_id"
tg:fieldName="song_id"
tg:keyField="true"
tg:visible="false" />
<com.ra.tablegrid.TableImageButton
android:id="#+id/play_song"
android:src="#drawable/play_button_up"
tg:displayOrder="02"
tg:fieldName="play_song"
tg:down_src_table="#drawable/play_button_down" />
<com.ra.tablegrid.TableImageButton
android:id="#+id/edit_song"
android:src="#drawable/edit_button_up"
tg:displayOrder="03"
tg:fieldName="edit_song"
tg:down_src_table="#drawable/edit_button_down" />
<com.ra.tablegrid.TableImageButton
android:id="#+id/delete_song"
android:src="#drawable/delete_button_up"
tg:displayOrder="04"
tg:fieldName="delete_song"
tg:down_src_table="#drawable/delete_button_down" />
<com.ra.tablegrid.TableTextView
android:id="#+id/song_name"
android:textSize="16sp"
tg:clickable="true"
tg:displayOrder="07"
tg:fieldName="song_name"
tg:sortable="true"
tg:fieldPercent="0.26"
tg:title="#string/song_name" />
<com.ra.tablegrid.TableTextView
android:id="#+id/artist"
android:textSize="13sp"
tg:displayOrder="10"
tg:fieldName="artist"
tg:secondarySorts="song_name"
tg:sortable="true"
tg:fieldPercent="0.13"
tg:title="#string/artist" />
<com.ra.tablegrid.TableTextView
android:id="#+id/cd_name"
android:textSize="13sp"
tg:displayOrder="15"
tg:fieldName="cd_name"
tg:secondarySorts="song_name"
tg:sortable="true"
tg:fieldPercent="0.14"
tg:title="#string/cd_name" />
<com.ra.tablegrid.TableTextView
android:id="#+id/category"
android:textSize="13sp"
tg:displayOrder="20"
tg:fieldName="category"
tg:secondarySorts="qualifier1,qualifier2,song_name"
tg:sortable="true"
tg:fieldPercent="0.08"
tg:title="#string/category" />
<com.ra.tablegrid.TableTextView
android:id="#+id/qualifier1"
android:textSize="13sp"
tg:displayOrder="25"
tg:fieldName="qualifier1"
tg:secondarySorts="qualifier2,song_name"
tg:sortable="true"
tg:fieldPercent="0.10"
tg:title="#string/qualifier1" />
<com.ra.tablegrid.TableTextView
android:id="#+id/qualifier2"
android:textSize="13sp"
tg:displayOrder="30"
tg:fieldName="qualifier2"
tg:secondarySorts="song_name"
tg:sortable="true"
tg:fieldPercent="0.14"
tg:title="#string/qualifier2" />
<com.ra.tablegrid.TableTextView
android:id="#+id/length"
android:textSize="13sp"
tg:displayOrder="35"
tg:fieldName="length"
tg:sortable="true"
tg:fieldPercent="0.08"
tg:title="#string/length" />
</com.ra.tablegrid.TableGrid>
</ScrollView>
And here is a code snipet for implementing the table.
mTableGrid.setInitialSort("song_name", true);
mTableGrid.setOnTableClickListener(new ITableClickListener() {
#Override
public void onTableClick(String columnName, String keyValue) {
MusicActivity.this.onTableClick(columnName, keyValue);
}
});
private void populateTable(ArrayList<DisplaySong> displaySongs) {
mTableGrid.clearData();
for (DisplaySong song : displaySongs) {
mTableGrid.addDataRow(createTableDataRow(song));
}
mTableGrid.buildTable();
}

Related

get popup valus and send it to mail in android

i have an app which has a form values..
Title...
username...
email...
send(Button)
and this form is shown as popup window
my popup xml code is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/compose_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C0000000"
android:visibility="visible"
android:gravity="center"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:id="#+id/popup"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#f47d7d"
android:layout_gravity="center"
android:paddingLeft="20sp"
android:paddingRight="60sp"
android:paddingTop="20sp"
android:paddingBottom="20sp"
>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Popup"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/topicname"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Topic Name" />
<EditText
android:id="#+id/topiccontent"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Topic Headings" />
<EditText
android:id="#+id/usermail"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter your mail" />
<Button
android:id="#+id/close"
android:layout_marginTop="10dp"
android:layout_gravity=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</RelativeLayout>
firstly,my popup window form is not editable..please suggest something to make it editable
secondly, i want to get these values(title,username and email) and send it to specified email address on send button click.
Thanks in advance
BackgroundMail.newBuilder(getActivity())
.withUsername("Your newly created Gmail account")
.withPassword("your password")
.withMailto(email.getText().toString())
.withSubject("TEST ANDROID STUDIO")
.withBody("ELOWWWWW")
.withOnSuccessCallback(new BackgroundMail.OnSuccessCallback() {
#Override
public void onSuccess() {
//do some magic
Log.d(TAG,"MAI SENDED");
}
})
.withOnFailCallback(new BackgroundMail.OnFailCallback() {
#Override
public void onFail() {
Log.d(TAG,"MAI FAILED");
}
})
.send();
Call the above method inside your send button clicklistner
to import the library as module get it from this link https://github.com/yesidlazaro/GmailBackground

I'm completely stumped as to which Android Adapter to inherit/use

I have a data-structure which is of type:
ArrayList<ArrayList<String>>;
...It contains a set of elements of a news feed; each element is itself a list of fields and each field is a tuple(key:value) where both key&value are of type String.
NOTE: the reason fields are stored in ArrayList is I don't always know how many the feed-parser will spurt out.
The view:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:id="#+id/news"
android:text="#string/news_and_events"
android:layout_row="6"
android:layout_column="4"
android:layout_columnSpan="3"
android:layout_rowSpan="3"
android:width="180dp"
android:height="245dp"
android:layout_marginBottom="10dp">
<!--FEED-->
<ListView
android:id="#android:id/list"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
</RelativeLayout>
The row-template I want to use is:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:id="#+id/picture"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginRight="6dip"
android:contentDescription=""
/>
<!--STARTING WITH title-->
<TextView
android:id="#+id/title"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="#id/picture"
android:ellipsize="marquee"
android:singleLine="true"
android:text=""
android:textSize="20sp"
/>
<TextView
android:id="#+id/body"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
As you can see there are 3-fields: title, body, image (a news feed).
So I'm completely stumped as to what type of adapter I should use.
All the ones' I've looked at don't seem to match what I want to do; specifically because of the data-structure I'm using.
Perhaps I should use a cursor adapter?
If so, how would I map this into a Relational-database?!
I think you should try using a BaseAdapter, it's the most flexible adapter Android has(I think)...
By doing so, you can implement a custom Adapter, which goes thru the ArrayList(using 2 cycles for extracting) and then parsing it to the visual components you specified.
Since it's constructor receives the context, the view and the data, you'll have the ImageView and so, there.

android - set text for spinner in <include />

I would like to set text for the spinners in the layout reused. However, only the first spinner is set. How to set text for all spinners with same id?
Also, I would like to ask how add another skillfield.xml to fragment_skill.xml when clicking the imageview?
Thank you.
fragment_skill.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/skillInfo" >
<RelativeLayout
android:id="#+id/OCC"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/occ"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="#string/occSkill"
android:textSize="20sp" />
<TextView
android:id="#+id/occPt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_toEndOf="#id/occ"
android:text=""
android:textSize="20sp" />
<include
android:id="#+id/oocSkill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/occ"
layout="#layout/skillfield" />
<ImageView
android:id="#+id/addOccSkill"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_below="#id/oocSkill"
android:contentDescription="#string/delSkill"
android:src="#android:drawable/ic_input_add" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/ORI"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/OCC" >
<TextView
android:id="#+id/ori"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="#string/oriSkill"
android:textSize="20sp" />
<TextView
android:id="#+id/oriPt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_toEndOf="#id/ori"
android:text=""
android:textSize="20sp" />
<include
android:id="#+id/oriSkill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/ori"
layout="#layout/skillfield" />
<ImageView
android:id="#+id/addOriSkill"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_below="#id/oriSkill"
android:contentDescription="#string/delSkill"
android:src="#android:drawable/ic_input_add" />
</RelativeLayout>
</RelativeLayout>
skillfield.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/addSkillField" >
<Spinner
android:id="#+id/selectSkill"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp" />
<TextView
android:id="#+id/skillPt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text=""
android:textSize="20sp" />
<ImageView
android:id="#+id/addSkill"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:contentDescription="#string/delSkill"
android:src="#android:drawable/ic_delete" />
</LinearLayout>
In MainActivity.class
skill = (Spinner) findViewById(R.id.selectSkill);
ArrayAdapter<CharSequence> skillAdapter = ArrayAdapter.createFromResource(context, R.array.skills, R.layout.spinner);
skillAdapter.setDropDownViewResource(R.layout.spinner_down);
skill.setAdapter(skillAdapter);
how to setup Spinner with the same ID
It is true that if you do this:
skill = (Spinner) findViewById(R.id.selectSkill);
You will be only able to get the first Spinner. I don't think you can add new Spinner dynamically by using <include>.
Here's the main idea of how to achieve what you need:
In fragment_skill.xml, you need to add an empty container view. This container should be inserted in the place you want to add your Spinner every time the button is clicked. This container will hold your Spinners that are added.
Let's say you want to insert here:
<RelativeLayout...>
<TextView.../>
<TextView.../>
<!-- here is where you want to insert your Spinner -->
<ImageView.../>
</RelativeLayout...>
So you add a LinearLayout at that spot, like this:
<RelativeLayout...>
<TextView.../>
<TextView.../>
<LinearLayout
android:id="#+id/container"
android:orientation="vertical
... />
<ImageView.../>
</RelativeLayout...>
You can add any other type of layout, depending what you need, it doesn't have to be LinearLayout. After that, you grab that LinearLayout from your activity/fragment like this:
LinearLayout mContainer; // make this instance variable
mContainer = (LinearLayout)findViewById(R.id.container);
Also grab the button so that you can set up a listener, let's assume it's called Button mButton:
mButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
addNewSpinner();
});
So when the button is clicked, you will call addNewSpinner(). Now, make a method called addNewSpinner(). Inside, the method, we will be inflating skillfield.xml. The method should look something like this:
public void addNewSpinner(){
View view = getLayoutInflater().inflate(R.layout.skillfield, null);
Spinner skill = (Spinner) view.findViewById(R.id.selectSkill);
ArrayAdapter<CharSequence> skillAdapter = ArrayAdapter.createFromResource(context, R.array.skills, R.layout.spinner);
skillAdapter.setDropDownViewResource(R.layout.spinner_down);
skill.setAdapter(skillAdapter);
mContainer.addView(skill);
}
If you are not sure what inflate means, here is the explanation:
Instantiates a layout XML file into its corresponding View objects.
Hope it helps!

GridLayout’s rowOrderPreserved and columnOrderPreserved

Can someone please explain what GridLayout’s rowOrderPreserved and columnOrderPreserved mean?
I don't understand the docs. What is the difference between setting the value to true or false. An illustration wil be very helpful.
Consider the following piece of code with GridLayout:
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:useDefaultMargins="true"
android:alignmentMode="alignBounds"
android:columnOrderPreserved="true"
android:columnCount="4"
>
<TextView
android:text="Email setup"
android:textSize="32dip"
android:layout_columnSpan="4"
android:layout_gravity="center_horizontal"
/>
<TextView
android:text="Email address:"
android:layout_gravity="left"
/>
<EditText
android:ems="10"
/>
<TextView
android:text="Password:"
android:layout_column="0"
android:layout_gravity="right"
/>
<EditText
android:ems="8"
/>
<Button
android:text="Next"
android:layout_row="4"
android:layout_column="3"
/>
</GridLayout>
This xml generates a view as follows in which the 'Next'-button is outside of the screen:
This is because the first EditText element defines the width of the second column. When defining the 'Next' button in the fourth column, it has to be right of the second column.
Now, changing the attribute columnOrderPreserved to false gives android the liberty to place the horizontal column boundaries in whatever order best fits the given constraints. (See the documentation) The result is as in this image:

ontouchListener code not running?

I have a toggleButton that should run code when I press it and more when I let go. However it's not working like that at all, just like a toggle button normally does, I press it and it changes state, it doesn't call the touchlistener code at all.
In my in_call_card.xml I have:
<ToggleButton
android:id="#+id/PTT_button5"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="#string/ptt5"
android:layout_weight="50"
android:textOn="Push To Talk On"
android:textOff="Push To Talk Off"
android:background="#drawable/btn_lightblue_glossy"
android:textColor="#android:color/white"
android:textSize="15sp"
/>
in onCreate I have setContent to in_card_main.xml so I have to inflate the layout to use the button in in_call_card.xml. Here is my code, but it never runs when i am pressing the button:
LayoutInflater inflater = getLayoutInflater();
View otherLayout = inflater.inflate(R.layout.in_call_card, null);
final ToggleButton toggle = (ToggleButton) otherLayout.findViewById(R.id.PTT_button5);
toggle.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(getApplicationContext(), "woot7", Toast.LENGTH_SHORT).show();
//may need to change to loop and send all ids.
int callId = 0;
for (SipCallSession callInfo : callsInfo) {
callId = callInfo.getCallId();
Log.e(TAG, ""+callInfo.getCallId());
}
final int id= callId;
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
toggle.setBackgroundResource(R.drawable.btn_blue_glossy);
toggle.setChecked(true);
OnDtmf(0, 17, 10);
OnDtmf(0, 16, 9);
OnDtmf(id, 17, 10);
OnDtmf(id, 16, 9);
break;
case MotionEvent.ACTION_UP:
// Toast.makeText(getApplicationContext(), "woot", Toast.LENGTH_LONG).show();
//release
toggle.setBackgroundResource(R.drawable.btn_lightblue_glossy);
toggle.setChecked(false);
OnDtmf(0, 18, 11);
OnDtmf(0, 18, 11);
OnDtmf(id, 18, 11);
OnDtmf(id, 18, 11);
break;
}
return false;
}
});
EDIT:
in_call_main:
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010 Regis Montoya (aka r3gis - www.r3gis.fr)
This file is part of CSipSimple.
CSipSimple is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
If you own a pjsip commercial license you can also redistribute it
and/or modify it under the terms of the GNU Lesser General Public License
as an android library.
CSipSimple is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CSipSimple. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/mainFrame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ViewStub
android:id="#+id/dropZones"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="#layout/in_call_drop_zones" />
<LinearLayout
android:id="#+id/inCallContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="3"
android:orientation="horizontal" >
<!--
Can we do better than using two linear layouts here?
The problem is that RelativeLayout doesn't allow to use weight and
plays bad with hidden childs and above/below only support one id
-->
<!-- Grid for active calls -->
<com.csipsimple.ui.incall.InCallInfoGrid
android:id="#+id/activeCallsGrid"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2"
android:paddingBottom="4dip"
android:paddingTop="4dip"
tools:ignore="NestedWeights" />
<!-- Grid for held calls -->
<com.csipsimple.ui.incall.InCallInfoGrid
android:id="#+id/heldCallsGrid"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/in_call_held_background"
android:padding="4dip"
android:visibility="gone" />
</LinearLayout>
<!-- Answer slider/buttons -->
<com.csipsimple.ui.incall.locker.InCallAnswerControls
android:id="#+id/inCallAnswerControls"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="2"
android:visibility="gone" />
<!-- Wraps split action bar manually managed -->
<com.csipsimple.ui.incall.InCallControls
android:id="#+id/inCallControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/incall_bottom_bar_bg" />
</LinearLayout>
<com.csipsimple.ui.incall.locker.ScreenLocker
android:id="#+id/lockerOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#8000"
android:visibility="gone" >
<!--
<TextView android:id="#+id/lockerIcon"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" android:layout_marginBottom="70dip"
android:text="#string/touch_lock" android:textAppearance="?android:attr/textAppearanceLarge"
android:background="#drawable/dialpad_lock" />
-->
</com.csipsimple.ui.incall.locker.ScreenLocker>
<!-- <ToggleButton
android:id="#+id/PTT_button3"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="#string/ptt3"
android:layout_weight="50"
android:textOn="Push To Talk On"
android:textOff="Push To Talk Off"
android:background="#drawable/btn_lightblue_glossy"
android:textColor="#android:color/white"
android:textSize="15sp"
/> -->
</RelativeLayout>
in_call_card:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/call_card_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:padding="2dip"
tools:ignore="Overdraw" >
<com.csipsimple.widgets.MaxScaleImageView
android:id="#+id/contact_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/call_action_bar"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:contentDescription="#string/empty_description"
android:scaleType="centerCrop"
android:src="#drawable/ic_contact_picture_180_holo_light" />
<RelativeLayout
android:id="#+id/contact_name_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#9e808080"
android:gravity="center_vertical" >
<!--
<EditText
android:id="#+id/editText1"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
-->
<com.csipsimple.widgets.MarqueeTextView
android:id="#+id/contact_name_display_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:padding="5dip"
android:singleLine="true"
android:textColor="#android:color/white"
android:textSize="25sp" />
<com.csipsimple.widgets.MarqueeTextView
android:id="#+id/contact_name_sip_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/contact_name_display_name"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:padding="2dip"
android:singleLine="true"
android:textColor="#android:color/white"
android:textSize="15sp" />
<Chronometer
android:id="#+id/elapsedTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textSize="20sp" />
</RelativeLayout>
<TextView
android:id="#+id/call_status_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/contact_name_bar"
android:layout_marginTop="1dip"
android:background="#c818617b"
android:gravity="center_vertical|right"
android:padding="3dip"
android:text="#string/call_state_calling"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="15sp" />
<RelativeLayout
android:id="#+id/call_secure_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/call_status_text"
android:layout_marginTop="1dip"
android:background="#c8d4aa00" >
<ImageView
android:id="#+id/call_secure_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="2dip"
android:contentDescription="#string/empty_description"
android:src="#drawable/stat_sys_vp_phone_call" />
<TextView
android:id="#+id/call_secure_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/call_secure_icon"
android:padding="2dip"
android:textColor="#android:color/white"
android:textSize="15sp" />
</RelativeLayout>
<FrameLayout
android:id="#+id/call_action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/end_call_bar"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true"
android:layout_marginTop="2dip"
android:background="#000000" />
<LinearLayout
android:id="#+id/end_call_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="2dip"
android:background="#drawable/end_call_background"
android:orientation="horizontal" >
<!-- android:onClick="pushtotalk3" -->
<ToggleButton
android:id="#+id/PTT_button5"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="#string/ptt5"
android:layout_weight="50"
android:textOn="Push To Talk On"
android:textOff="Push To Talk Off"
android:background="#drawable/btn_lightblue_glossy"
android:textColor="#android:color/white"
android:textSize="15sp"
/>
<ImageButton
android:id="#+id/endButton"
style="?attr/actionButtonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="50"
android:contentDescription="#string/done"
android:minHeight="64dip"
android:src="#drawable/ic_end_call" />
</LinearLayout>
</RelativeLayout>
It's not your listener. Your listener works fine, with ToggleButton or any other kind of view. With the return false at the end, your onTouchListener should get called and an onClickListener- if one exists - gets called.
The reason why you get nothing when you press the button is, that the button is not on your screen. You inflate it in your code, but without a parent and I cant see any code, that actually adds the inflated ToggleButton to any layout. So, whatever you have on your screen that you press, it's not that button your onTouchListener listens.
I recommend to make the ToggleButtonpart of you layout or - depending on your App Design - create a new Layout and Activity for this.
EDIT According to the posted layouts.
What I understand is, that you have two full layouts: in_card_main.xml and in_call_card.xml but only one Activity. Is that right? If yes, the solution is to have one Activity for each layout and call the Activities with startActivity().
If you use setContentView(int) you have to use findViewById(int) because the activity inflates the XML for you.
For the moment you are putting a listener on a button which is not displayed, because you get it from the layout you have inflated, but not from the one the activity hold.
2 solutions :
Add the missing ending setContentView(otherLayout) call to tell your activity to display the layout you have inflated
Use setContentView(R.layout.in_call_card) and then retrieve the view by using only findViewById(R.id.PTT_button5); to tell you activity to display the layout 'in_call_card' before asking it to search for the view with the id 'R.id.PTT_button5' in its hierarchy

Categories

Resources