<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--other views-->
<net.cachapa.expandablelayout.ExpandableLayout
android:id="@+id/expand_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:el_duration="500"
app:el_expanded="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/name"
style="@style/EditText_BorderedMiddle_Grey_F"
android:layout_width="match_parent"
android:layout_weight="1"
android:hint="@string/dialog_categories_hintname"/>
<ImageView
android:id="@+id/submit"
style="@style/ImageView_FilledMiddle_Blue_F_50"
android:src="@drawable/ic_check_white_48dp"/>
</LinearLayout>
</net.cachapa.expandablelayout.ExpandableLayout>
<!--other views-->
</LinearLayout>
我怀疑输出(最后3行)
应该是
public class CategoriesDialog extends AppCompatDialog {
//other codes
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.setWindowGravity(getWindow(), Gravity.BOTTOM);
//...
}
@OnClick(R.id.add)
public void onAddClick() {
expandAdd.toggle();
}
}
public class Utils {
public static void setWindowGravity(Window window, int gravity) {
WindowManager.LayoutParams attributes = window.getAttributes();
attributes.gravity = gravity;
window.setAttributes(attributes);
}
}
因为
using namespace std;
static int index = 0;
template<typename T>
class vertexInfo
{
public:
typename map< T, int>:: iterator vtxMapLoc;
vertexInfo<T>(int index)
{}
vertexInfo<T>( typename map<T, int> :: iterator& iter) : vtxMapLoc{*iter}
{}
};
template <typename T>
class graph
{
private:
typename map< T, int > :: iterator iter;
map <T,int> vtxMap;
vector<vertexInfo<T> > vInfo;
public:
void addEdge( graph<T>& , const T& , const T&, int );
void show(graph<T>& );
void show_map_element( graph<T>& );
};
int main()
{
graph<char> g;
g.addEdge(g,'A','B', 2);
g.addEdge(g,'A','C', 3);
g.addEdge(g,'B','D', 5);
g.addEdge(g,'C','D', 1);
g.addEdge(g,'B','C', 7);
g.addEdge(g,'D','E', 4);
g.show(g);
g.show_map_element(g);
return 0;
}
template <typename T>
void graph<T> :: addEdge ( graph<T> & g, const T& v1 , const T& v2, int w)
{
pair <map <char, int> :: iterator, bool> ret ;
ret = g.vtxMap.insert(pair <char, int >( v1, index));
if( ret.second)
{
g.vInfo.push_back(index);
(g.vInfo[index].vtxMapLoc) = vtxMap.find(index);
index++;
}
ret = g.vtxMap.insert(pair <char, int >(v2 , index));
if( ret.second)
{
g.vInfo.push_back(index);
(g.vInfo[index].vtxMapLoc) = vtxMap.find(index);
index++;
}
}
}
template<typename T>
void graph<T> :: show( graph<T>& g)
{
for( g.iter = g.vtxMap.begin(); g.iter != g.vtxMap.end(); g.iter++)
{
cout<< (*(g.iter)).first <<" - >" << (*(g.iter)).second <<endl;
}
}
template<typename T>
void graph<T> :: show_map_element( graph<T>& g)
{
cout<< (*g.vInfo[2].vtxMapLoc).first<<endl;
cout<< (*g.vInfo[3].vtxMapLoc).second<<endl;
cout<< (*g.vInfo[4].vtxMapLoc).first<<endl;
}
Output :
A -> 0
B -> 1
C -> 2
D -> 3
E -> 4
( nothing printed )
0
( nothing printed )
指向(C,2),它首先是C
C
3
E
指向(D,3),其次是3
(*g.vInfo[2].vtxMapLoc)
指向(E,4),它的第一个是E
似乎向量(*g.vInfo[3].vtxMapLoc)
未正确指向地图(*g.vInfo[4].vtxMapLoc)
vInfo
这指向正确吗?